Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/desmos/recursive_symbolize_keys.rb

Instance Method Summary collapse

Instance Method Details

#recursive_symbolize_keysObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/desmos/recursive_symbolize_keys.rb', line 3

def recursive_symbolize_keys
  hash = {}
  each_pair do |k,v|
    if v.is_a?(Hash)
      hash.store(k.to_sym,v.recursive_symbolize_keys)
    else
      hash.store(k.to_sym,v)
    end
  end
  hash
end

#recursive_symbolize_keys!Object



15
16
17
# File 'lib/desmos/recursive_symbolize_keys.rb', line 15

def recursive_symbolize_keys!
  self.replace(recursive_symbolize_keys)
end