Class: RedStorm::Configurator
- Inherits:
-
Object
- Object
- RedStorm::Configurator
- Defined in:
- lib/red_storm/configurator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(defaults = {}) ⇒ Configurator
constructor
A new instance of Configurator.
- #method_missing(sym, *args) ⇒ Object
- #set(attribute, value) ⇒ Object
Constructor Details
#initialize(defaults = {}) ⇒ Configurator
Returns a new instance of Configurator.
6 7 8 9 |
# File 'lib/red_storm/configurator.rb', line 6 def initialize(defaults = {}) @config = Backtype::Config.new defaults.each{|attribute, value| @config.put(attribute.to_s, value)} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
15 16 17 18 |
# File 'lib/red_storm/configurator.rb', line 15 def method_missing(sym, *args) config_method = "set#{self.class.camel_case(sym)}" @config.send(config_method, *args) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/red_storm/configurator.rb', line 4 def config @config end |
Instance Method Details
#set(attribute, value) ⇒ Object
11 12 13 |
# File 'lib/red_storm/configurator.rb', line 11 def set(attribute, value) @config.put(attribute.to_s, value) end |