Class: Planter::Config
Overview
Configuration class
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#[](key) ⇒ String
Get a config key.
-
#[]=(key, value) ⇒ Object
Set a config option.
-
#initialize ⇒ Config
constructor
Initialize a new Config object for a template.
-
#to_s ⇒ Object
String representation of the configuration.
Methods inherited from Hash
#deep_freeze, #deep_merge, #deep_thaw, #stringify, #stringify!, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!
Constructor Details
#initialize ⇒ Config
Initialize a new Config object for a template
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/planter/config.rb', line 11 def initialize super() @config = initial_config @template = Planter.template load_template die('No configuration found', :config) unless @config generate_accessors end |
Instance Attribute Details
#template ⇒ Object (readonly)
Returns the value of attribute template.
6 7 8 |
# File 'lib/planter/config.rb', line 6 def template @template end |
Instance Method Details
#[](key) ⇒ String
Get a config key
35 36 37 |
# File 'lib/planter/config.rb', line 35 def [](key) @config[key] end |
#[]=(key, value) ⇒ Object
Set a config option
45 46 47 48 |
# File 'lib/planter/config.rb', line 45 def []=(key, value) @config[key.to_sym] = value generate_accessors end |
#to_s ⇒ Object
String representation of the configuration
25 26 27 |
# File 'lib/planter/config.rb', line 25 def to_s @config.to_s end |