Class: Stealth::Configuration
- Inherits:
-
Hash
- Object
- Hash
- Stealth::Configuration
- Defined in:
- lib/stealth/configuration.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ Configuration
constructor
A new instance of Configuration.
- #method_missing(method, *args) ⇒ Object
- #set_default(key, default_value) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 13 |
# File 'lib/stealth/configuration.rb', line 7 def initialize(hash) hash.each do |k, v| self[k] = store(v) end self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/stealth/configuration.rb', line 15 def method_missing(method, *args) key = create_config_attribute(method) if setter?(method) self[key] = args.first else self[key] end end |
Instance Method Details
#set_default(key, default_value) ⇒ Object
25 26 27 28 29 |
# File 'lib/stealth/configuration.rb', line 25 def set_default(key, default_value) if self[key.to_s] == nil self[key.to_s] = store(default_value) end end |