Skip to content

Instantly share code, notes, and snippets.

@kohgpat
Created March 29, 2013 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohgpat/5268416 to your computer and use it in GitHub Desktop.
Save kohgpat/5268416 to your computer and use it in GitHub Desktop.
core_ext/hash.rb
class Hash
def symbolize_keys
inject({}) do |options, (key, value)|
options[(key.to_sym rescue key) || key] = value
options
end
end
def symbolize_keys!
self.replace(self.symbolize_keys)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment