Method: Confy::Config.path

Defined in:
lib/confy/config.rb

.path(config, str = '') ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/confy/config.rb', line 87

def self.path(config, str = '')
  type = config.class

  if type == Array
    config.each_with_index do |value, key|
      self.path(value, "#{str}_#{key}")
    end
  elsif type == Hash
    config.each do |key, value|
      self.path(value, "#{str}_#{key.upcase}")
    end
  elsif type == TrueClass
    ENV[str.slice(1, str.length)] = '1'
  elsif type == FalseClass
    ENV[str.slice(1, str.length)] = '0'
  else
    ENV[str.slice(1, str.length)] = config.to_s
  end
end