Class: Dandelion::Config
- Inherits:
-
Object
- Object
- Dandelion::Config
- Defined in:
- lib/dandelion/config.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #defaults(values) ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
8 9 10 11 |
# File 'lib/dandelion/config.rb', line 8 def initialize( = {}) @path = [:path] @data = @path ? load : ([:data] || {}) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/dandelion/config.rb', line 6 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/dandelion/config.rb', line 6 def path @path end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/dandelion/config.rb', line 13 def [](key) @data[key] || @data[key.to_s] end |
#[]=(key, value) ⇒ Object
17 18 19 |
# File 'lib/dandelion/config.rb', line 17 def []=(key, value) @data[key.to_s] = value end |
#defaults(values) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/dandelion/config.rb', line 21 def defaults(values) values.each do |k, v| if self[k].nil? self[k] = v end end self end |