Module: HashWrangler
- Included in:
- AlsoEnergy::Client, AlsoEnergy::HardWare, AlsoEnergy::Site
- Defined in:
- lib/also_energy/hash_wrangler.rb
Instance Method Summary collapse
-
#find_in_hash(key, object = self, found = nil) ⇒ Object
credit to stackoverflow.com/questions/8301566/.
Instance Method Details
#find_in_hash(key, object = self, found = nil) ⇒ Object
credit to stackoverflow.com/questions/8301566/
3 4 5 6 7 8 9 10 |
# File 'lib/also_energy/hash_wrangler.rb', line 3 def find_in_hash(key, object=self, found=nil) if object.respond_to?(:key?) && object.key?(key) return object[key] elsif object.is_a? Enumerable object.find { |*a| found = find_in_hash(key, a.last) } return found end end |