Class: Object

Inherits:
BasicObject
Defined in:
lib/utils.rb

Instance Method Summary collapse

Instance Method Details

#stringify_keysObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/utils.rb', line 39

def stringify_keys
  case self
  when Hash
    hash = {}
    each {|k, v| hash[k.to_s] = v.stringify_keys}
    hash
  when Array
    map {|x| x.stringify_keys}
  else
    self
  end
end

#symbolize_keysObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/utils.rb', line 25

def symbolize_keys
  case self
  when Hash
    hash = {}
    each {|k, v| hash[k.to_sym] = v.symbolize_keys}
    hash
  when Array
    map {|x| x.symbolize_keys}
  else
    self
  end
end