Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#symbolize_keys!Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/core_ext/hash.rb', line 2

def symbolize_keys!
  t=self.dup
  self.clear
  t.each_pair do |k,v|
    case v
    when Hash
      v.symbolize_keys!
    when Array
      v.each do |e|
        if e.kind_of?(Hash)
          e.symbolize_keys!
        end
      end
    end
    self[k.to_sym] = v
    self
  end
  self
end