Module: Colore::Utils

Defined in:
lib/utils.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.symbolize_keys(obj) ⇒ Object

Deep conversion of all hash keys to symbols.


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/utils.rb', line 6

def self.symbolize_keys obj
  case obj
    when Hash
      h = {}
      obj.each do |k,v|
        h[k.to_sym] = symbolize_keys v
      end
      h
    when Array
      obj.map{ |o| symbolize_keys o }
    else
      obj
  end
end

Instance Method Details

#symbolize_keys(obj) ⇒ Object

Deep conversion of all hash keys to symbols.


22
23
24
# File 'lib/utils.rb', line 22

def symbolize_keys obj
  Colore::Utils.symbolize_keys obj
end