Module: CartoJson::Utils

Defined in:
lib/carto_json/utils.rb

Class Method Summary collapse

Class Method Details

.symbolize_keys(arg) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/carto_json/utils.rb', line 3

def self.symbolize_keys(arg)
  case arg
  when Array
    arg.map { |elem| symbolize_keys elem }
  when Hash
    Hash[
      arg.map { |key, value|  
        k = key.is_a?(String) ? key.to_sym : key
        v = symbolize_keys value
        [k,v]
      }]
  else
    arg
  end
end