Skip to content

Instantly share code, notes, and snippets.

@softarn
Created August 21, 2012 15:49
Show Gist options
  • Save softarn/3416739 to your computer and use it in GitHub Desktop.
Save softarn/3416739 to your computer and use it in GitHub Desktop.
Symbolize keys for nested hashes, tested in ruby 1.8.7
def self.recursive_symbolize_keys! hash
hash.symbolize_keys!
inner = hash.values.select{|v| v.is_a? Hash}.each{|h| recursive_symbolize_keys!(h)}
inner.each {|inner| hash.merge(inner)}
hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment