Class: Spawno::Configuration
- Inherits:
-
Object
- Object
- Spawno::Configuration
- Defined in:
- lib/spawno/config.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_from_file(path) ⇒ Object
- #method_missing(method_name) ⇒ Object
- #setup(path = nil) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 |
# File 'lib/spawno/config.rb', line 7 def initialize self.settings = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
19 20 21 |
# File 'lib/spawno/config.rb', line 19 def method_missing(method_name) settings[method_name.to_s] end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
5 6 7 |
# File 'lib/spawno/config.rb', line 5 def settings @settings end |
Instance Method Details
#load_from_file(path) ⇒ Object
11 12 13 |
# File 'lib/spawno/config.rb', line 11 def load_from_file(path) self.settings.merge! YAML.load_file(path) end |
#setup(path = nil) ⇒ Object
15 16 17 |
# File 'lib/spawno/config.rb', line 15 def setup(path = nil) load_from_file(path) if path end |