Class: Marconi::Config
- Inherits:
-
Object
- Object
- Marconi::Config
- Defined in:
- lib/marconi/config.rb
Instance Attribute Summary collapse
-
#bunny_params ⇒ Object
Returns the value of attribute bunny_params.
-
#keepalive ⇒ Object
Returns the value of attribute keepalive.
-
#listeners ⇒ Object
Returns the value of attribute listeners.
-
#name ⇒ Object
Returns the value of attribute name.
-
#short_name ⇒ Object
Returns the value of attribute short_name.
Instance Method Summary collapse
-
#initialize(config_file = nil, env = 'test') ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(config_file = nil, env = 'test') ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/marconi/config.rb', line 5 def initialize(config_file = nil, env = 'test') if Object.const_defined?(:Rails) config_file ||= "#{Rails.root}/config/queues.yml" env = Rails.env end unless File.exists?(config_file) raise "Could not find #{config_file}" end params = YAML.load_file(config_file) self.name = params['name'] || raise("Wait... Who am I?") self.short_name = params['short_name'] || raise("w8... hu m i?") self.keepalive = !!params['keepalive'] self.listeners = params['listeners'] || [] self.bunny_params = params['bunny'] && params['bunny'][env] if bunny_params self.bunny_params.symbolize_keys! else puts "Warning: No config specified for #{env}" self.bunny_params = {} end end |
Instance Attribute Details
#bunny_params ⇒ Object
Returns the value of attribute bunny_params.
4 5 6 |
# File 'lib/marconi/config.rb', line 4 def bunny_params @bunny_params end |
#keepalive ⇒ Object
Returns the value of attribute keepalive.
4 5 6 |
# File 'lib/marconi/config.rb', line 4 def keepalive @keepalive end |
#listeners ⇒ Object
Returns the value of attribute listeners.
4 5 6 |
# File 'lib/marconi/config.rb', line 4 def listeners @listeners end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/marconi/config.rb', line 4 def name @name end |
#short_name ⇒ Object
Returns the value of attribute short_name.
4 5 6 |
# File 'lib/marconi/config.rb', line 4 def short_name @short_name end |