hash_pick 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ab66b9a5a34241d4501d248ac0493ca8254e81c
4
- data.tar.gz: 3234a0b99d870f14bb7e24c978132d9aef498fce
3
+ metadata.gz: 7dd8624c8171843a2eef1aff8cc3a36703a73ed8
4
+ data.tar.gz: 3e7e026f72fdbcf650ba94a1297250ae5400698a
5
5
  SHA512:
6
- metadata.gz: '059c479e8ddb54cda612938a2016df22b831b09b987305eb6a8c01afd8c0b9df251d88736b1021b3b5ef3c004052f9dc2f5c65f679690afdbdd79b2f2596bbd1'
7
- data.tar.gz: 3b8eaddc6159f30cc3cf3653b62ca2a9d34e7caf3f99613a41b3d612c27d45cb945cf7ea2d8fdd8a5aefc495f42498eca96cdb77b2822024717fb0aa53a9dfbf
6
+ metadata.gz: '08237ef3fe7264baffb72f88d34645f50edd0864ac39aa7672d84740b2bfd167bce45447efe93bc4590784095a525296199d66f2079b9b884c8dcae691fd24e2'
7
+ data.tar.gz: 975e6f37633a6da46bd54ef97db4c3b390e2697d981421834576da98f6ae0a96d89e997fff8f9a93f84f164be811cd6b4a004a05fc6a31f6bda1ea21d1294c5a
@@ -1,3 +1,3 @@
1
1
  module HashPick
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/lib/hash_pick.rb CHANGED
@@ -61,8 +61,10 @@ module HashPick
61
61
  # General form of hash path iteration
62
62
  #
63
63
  # Passes to +block+, the dictionary and hash key for each iteration of the hash path, using
64
- # the return value of the block as the dictionary for the next iteration, or as the return
65
- # value of the last iteration. If the block throws +:break+, iteration is aborted.
64
+ # the return value of the block as the dictionary for the next iteration, or in the case of
65
+ # the last iteration, as the return value. If the block returns a non-dictionary in any but
66
+ # the last iteration, or if the block throws +:break+, iteration is aborted and +nil+ is
67
+ # returned.
66
68
  #
67
69
  # @example Complex hash path semantics
68
70
  #
@@ -93,6 +95,7 @@ module HashPick
93
95
  # an ordered list of path keys.
94
96
  # @return [Object] the value of the last iteration.
95
97
  # @return [nil] if +block+ throws +:break+ in any iteration.
98
+ # @return [nil] if +block+ returns a non-dictionary for any but the last iteration.
96
99
  # @raise [ArgumentError] if +hash+ isn't a dictionary.
97
100
  # @raise [ArgumentError] if +path+ isn't a list.
98
101
  #
@@ -165,7 +168,7 @@ module HashPick
165
168
  #
166
169
  def self.symbol(hash, path)
167
170
  assert_non_nil_path_keys(path)
168
- object(hash, path.map(&:to_sym))
171
+ pick(hash, path) { |acc, p| acc[p.to_sym] }
169
172
  end
170
173
 
171
174
  ##
@@ -185,7 +188,7 @@ module HashPick
185
188
  #
186
189
  def self.string(hash, path)
187
190
  assert_non_nil_path_keys(path)
188
- object(hash, path.map(&:to_s))
191
+ pick(hash, path) { |acc, p| acc[p.to_s] }
189
192
  end
190
193
 
191
194
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_pick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Hearn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-14 00:00:00.000000000 Z
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler