Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/forge/config/initializers/class_extensions/hash.rb

Instance Method Summary collapse

Instance Method Details

#recursive_symbolize_keys!Object



2
3
4
5
6
7
8
9
# File 'lib/forge/config/initializers/class_extensions/hash.rb', line 2

def recursive_symbolize_keys!
  symbolize_keys!
  # symbolize each hash in .values
  values.each{|h| h.recursive_symbolize_keys! if h.is_a?(Hash) }
  # symbolize each hash inside an array in .values
  values.select{|v| v.is_a?(Array) }.flatten.each{|h| h.recursive_symbolize_keys! if h.is_a?(Hash) }
  self
end