module Hashie::Extensions::DeepFind
def deep_find_all(key)
my_hash[:users] = [{location: {address: '123 Street'}}, {location: {address: '234 Street'}}]
my_hash = MyHash.new
end
include Hashie::Extensions::DeepFind
class MyHash < Hash
options.deep_find_all(:address) # => ['123 Street', '234 Street']
options.extend(Hashie::Extensions::DeepFind)
options = {users: [{location: {address: '123 Street'}}, {location: {address: '234 Street'}}]}
a key and returns all occurrences of the key.
Performs a depth-first search on deeply nested data structures for
def deep_find_all(key) matches = _deep_find_all(key) matches.empty? ? nil : matches end