Created
December 7, 2015 19:10
-
-
Save glucero/5b8d4157758ce1fc819d 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
class Hash | |
def to_proc | |
method(:[]).to_proc | |
end | |
def dig(*keys) | |
result = fetch(keys.shift, nil) | |
if result.is_a?(Hash) && keys.any? | |
result.dig *keys | |
else | |
result | |
end | |
end | |
end | |
Author
glucero
commented
Dec 7, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment