Class: Easy::Configuration::Structure
- Inherits:
-
Object
- Object
- Easy::Configuration::Structure
- Defined in:
- lib/easy/configuration/structure.rb
Instance Method Summary collapse
-
#initialize(default_values = {}) ⇒ Structure
constructor
A new instance of Structure.
- #merge!(structure, ignore_defaults = true) ⇒ Object
Constructor Details
#initialize(default_values = {}) ⇒ Structure
Returns a new instance of Structure.
5 6 7 8 9 10 |
# File 'lib/easy/configuration/structure.rb', line 5 def initialize(default_values = {}) @values = default_values.dup @changed = Hash.new { |hash, key| hash[key] = false } define_instance_methods end |
Instance Method Details
#merge!(structure, ignore_defaults = true) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/easy/configuration/structure.rb', line 12 def merge!(structure, ignore_defaults = true) if ignore_defaults @values.merge!(structure.values) { |key, v1, v2| structure.changed?(key) ? v2 : v1 } else @values.merge!(structure.values) end end |