Module: TinyCI::Symbolize

Included in:
Config
Defined in:
lib/tinyci/symbolize.rb

Instance Method Summary collapse

Instance Method Details

#map_value(thing) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/tinyci/symbolize.rb', line 11

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

#symbolize(hash) ⇒ Object

recursively make all keys of hash into symbols

Parameters:

  • hash (Hash)

    The hash



5
6
7
8
9
# File 'lib/tinyci/symbolize.rb', line 5

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