Last active
February 1, 2017 17:07
-
-
Save Naggi-Goishi/47b37c97aa2d102b4cfec684af76ff32 to your computer and use it in GitHub Desktop.
meta-programming that add method of keys_to_sym, which convert every keys to symbol type from string.
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 keys_to_sym | |
self.inject({}) do |hash, (key, value)| | |
value = value.keys_to_sym if value.class == Hash | |
hash[key.to_sym] = value | |
hash | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment