Class: Totoro::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/totoro/utils.rb

Instance Method Summary collapse

Instance Method Details

#underscore_hash_keys(value) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/totoro/utils.rb', line 5

def underscore_hash_keys(value)
  case value
  when Array
    value.map { |v| underscore_hash_keys(v) }
  when Hash
    Hash[value.map { |k, v| [underscorize(k), underscore_hash_keys(v)] }]
  else
    value
  end
end