Method: HashTools#deep_map_value
- Defined in:
- lib/hash_tools.rb
#deep_map_value(enum_of_hashes, path, separator: FWD_SLASH) ⇒ Array
Fetches a deeply nested key from each of the Hashes in a given Array.
arr = [
{'age' => 12, 'name' => 'Jack'},
{'age' => 25, 'name' => 'Joe'},
]
deep_map_value(arr, 'age') => [12, 25]
64 65 66 |
# File 'lib/hash_tools.rb', line 64 def deep_map_value(enum_of_hashes, path, separator: FWD_SLASH) enum_of_hashes.map{|h| deep_fetch(h, path, separator: separator)} end |