Module: Sinclair::Configurable
- Defined in:
- lib/sinclair/configurable.rb
Overview
Module capable of giving configuration capability
By extending Configurable, class receives the methods public .config, .reset_config and .configure and the private .configurable_with
Instance Method Summary collapse
-
#config ⇒ Config, Object
Returns current instance of config.
-
#configurable_with(*attributes) ⇒ Array<Symbol>
Adds a configuration option to config class.
-
#configure {|ConfigBuilder| ... } ⇒ Object
Set the values in the config.
-
#reset_config ⇒ NilClass
Cleans the current config instance.
Instance Method Details
#config ⇒ Config, Object
Returns current instance of config
the method returns the same instance until reset_config
is called
45 46 47 |
# File 'lib/sinclair/configurable.rb', line 45 def config config_factory.config end |
#configurable_with(*attributes) ⇒ Array<Symbol>
Adds a configuration option to config class
97 98 99 |
# File 'lib/sinclair/configurable.rb', line 97 def configurable_with(*attributes) config_factory.add_configs(*attributes) end |
#configure {|ConfigBuilder| ... } ⇒ Object
Set the values in the config
The block given is evaluated by the Sinclair::ConfigBuilder where each method missed will be used to set a variable in the config
57 58 59 |
# File 'lib/sinclair/configurable.rb', line 57 def configure(&block) config_factory.configure(&block) end |
#reset_config ⇒ NilClass
Cleans the current config instance
After cleaning it, #config will generate a new instance
51 52 53 |
# File 'lib/sinclair/configurable.rb', line 51 def reset_config config_factory.reset_config end |