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
7 8 9 10 |
# File 'lib/dandelion/config.rb', line 7 def initialize( = {}) @path = [:path] @data = @path ? load : ([:data] || {}) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/dandelion/config.rb', line 5 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/dandelion/config.rb', line 5 def path @path end |
Instance Method Details
#[](key) ⇒ Object
12 13 14 |
# File 'lib/dandelion/config.rb', line 12 def [](key) @data[key] || @data[key.to_s] end |
#[]=(key, value) ⇒ Object
16 17 18 |
# File 'lib/dandelion/config.rb', line 16 def []=(key, value) @data[key.to_s] = value end |
#defaults(values) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/dandelion/config.rb', line 20 def defaults(values) values.each do |k, v| if self[k].nil? self[k] = v end end self end |