Class: Micon::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(micon, name) ⇒ Config

Returns a new instance of Config.



3
4
5
# File 'lib/micon/config.rb', line 3

def initialize micon, name
  @micon, @name = micon, name
end

Instance Attribute Details

#miconObject (readonly)

Returns the value of attribute micon.



2
3
4
# File 'lib/micon/config.rb', line 2

def micon
  @micon
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/micon/config.rb', line 2

def name
  @name
end

Instance Method Details

#loadObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/micon/config.rb', line 7

def load
  files = []
  files.push *config_paths.collect{|path| find_file(path, $LOAD_PATH)}
  files.push *runtime_config_paths.collect{|path| find_file(path, [micon.runtime_path])}

  config = {}
  files.compact.each do |f|
    require 'yaml'
    c = YAML.load_file(f)
    next unless c
    raise "component config must be a Hash (#{f})!" unless c.is_a? Hash
    c.each{|k, v| config[k.to_sym] = v}
  end

  config.empty? ? nil : config
end