Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Created March 2, 2011 21:36
Show Gist options
  • Save yrgoldteeth/851791 to your computer and use it in GitHub Desktop.
Save yrgoldteeth/851791 to your computer and use it in GitHub Desktop.
class Hash
# Return a new hash with all keys converted to camelcase
def camelize_keys
dup.camelize_keys!
end
# Destructively convert all keys to camelcase
def camelize_keys!
keys.each do |key|
self[key.to_s.camelize(:lower)] = delete(key)
end
self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment