Class: Ixtlan::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/ixtlan/configurator.rb

Class Method Summary collapse

Class Method Details

.load(file) ⇒ Object



21
22
23
# File 'lib/ixtlan/configurator.rb', line 21

def self.load(file)
  symbolize_keys(YAML::load(ERB.new(IO.read(file)).result)) if File.exists?(file)
end

.symbolize_keys(h) ⇒ Object



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

def self.symbolize_keys(h)
  result = {}

  h.each do |k, v|
    v = ' ' if v.nil?
    if v.is_a?(Hash)
      result[k.to_sym] = symbolize_keys(v) unless v.size == 0
    else
      result[k.to_sym] = v unless k.to_sym == v.to_sym
    end
  end

  result
end