Class: Waffle::Config
- Inherits:
-
Object
- Object
- Waffle::Config
- Includes:
- Singleton
- Defined in:
- lib/waffle/config.rb
Instance Attribute Summary collapse
-
#config_hash ⇒ Object
readonly
Returns the value of attribute config_hash.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
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_hash ⇒ Object (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 |