Class: Waffle::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/waffle/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/waffle/config.rb', line 10

def initialize
  @config_hash = {'transport' => 'rabbitmq', 'url' => nil, 'encoder' => 'json'}

  filename = "config/waffle.yml"

  if defined? Rails
    fielname = "#{Rails.root}/config/waffle.yml"
  end

  if File.exists?(filename)
    loaded_config = YAML.load_file filename

    if defined?(Rails) && loaded_config[Rails.env]
      @config_hash.merge! loaded_config[Rails.env]
    else
      @config_hash.merge! loaded_config
    end
  end

end

Instance Attribute Details

#config_hashObject (readonly)

Returns the value of attribute config_hash.



8
9
10
# File 'lib/waffle/config.rb', line 8

def config_hash
  @config_hash
end

Class Method Details

.method_missing(m, *args, &block) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/waffle/config.rb', line 33

def method_missing(m, *args, &block)
  if self.instance.config_hash.has_key?(m.to_s)
    self.instance.config_hash[m.to_s]
  else
    super
  end
end