Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#deep_symbolize_keysObject



2
3
4
5
6
7
8
9
10
# File 'lib/core_ext/hash.rb', line 2

def deep_symbolize_keys
  inject({}) do |hash, item|
    key, value = item
    new_key = key.to_sym rescue key
    hash[new_key] = self[key]
    hash[new_key].deep_symbolize_keys if hash[new_key].kind_of?(Hash)
    hash
  end
end