Class: Ezframe::Config

Inherits:
Object show all
Defined in:
lib/ezframe/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.value_hObject

Returns the value of attribute value_h.



4
5
6
# File 'lib/ezframe/config.rb', line 4

def value_h
  @value_h
end

Class Method Details

.[](k) ⇒ Object



29
30
31
# File 'lib/ezframe/config.rb', line 29

def [](k)
  @value_h[k] if @value_h
end

.[]=(k, v) ⇒ Object



33
34
35
36
# File 'lib/ezframe/config.rb', line 33

def []=(k, v)
  @value_h||={}
  @value_h[k]=v
end

.inspectObject



38
39
40
# File 'lib/ezframe/config.rb', line 38

def inspect
  @value_h.inspect
end

.load_files(dir) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/ezframe/config.rb', line 6

def load_files(dir)
  unless @value_h
    Dir["#{dir}/*.yml"].each do |file|
      load_one_file(file)
    end
  end
end

.load_one_file(filename) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ezframe/config.rb', line 14

def load_one_file(filename)
  instr = File.open(filename, &:read)
  if instr.index("\#{")
    instr = Template.fill_in_text(instr)
  end
  begin
    yaml = YAML.load(instr)
  rescue
    mylog("YAML load error: #{filename}")
    return 
  end
  @value_h ||={}
  @value_h.update(yaml.recursively_symbolize_keys) if yaml.length>0
end