Created
June 13, 2013 16:16
-
-
Save getnashty/5775048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nested_hash_value(obj,key) | |
if obj.respond_to?(:key?) && obj.key?(key) | |
obj[key] | |
elsif obj.respond_to?(:each) | |
r = nil | |
obj.find{ |*a| r=nested_hash_value(a.last,key) } | |
r | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be something like