Module: SymbolizeHelper

Defined in:
lib/kashmir/extensions.rb

Class Method Summary collapse

Class Method Details

.map_value(thing) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/kashmir/extensions.rb', line 8

def self.map_value(thing)
  case thing
  when Hash
    symbolize_recursive(thing)
  when Array
    thing.map { |v| map_value(v) }
  else
    thing
  end
end

.symbolize_recursive(hash) ⇒ Object



2
3
4
5
6
# File 'lib/kashmir/extensions.rb', line 2

def self.symbolize_recursive(hash)
  {}.tap do |h|
    hash.each { |key, value| h[key.to_sym] = map_value(value) }
  end
end