Created
August 23, 2015 13:40
-
-
Save Malet/f13f69ba7fa84ed2b74a to your computer and use it in GitHub Desktop.
Hash Stringify Keys
This file contains hidden or 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 stringify_keys | |
result = {} | |
each_key do |key| | |
result[key.to_s] = if self[key].class == Hash | |
self[key].stringify_keys | |
else | |
self[key] | |
end | |
end | |
result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment