Class: Yamload::Defaults::Hash
- Inherits:
-
Object
- Object
- Yamload::Defaults::Hash
- Defined in:
- lib/yamload/defaults/hash.rb
Instance Attribute Summary collapse
-
#defaults ⇒ Object
Returns the value of attribute defaults.
Instance Method Summary collapse
-
#initialize(defaults = nil) ⇒ Hash
constructor
A new instance of Hash.
- #merge(hash) ⇒ Object
Constructor Details
#initialize(defaults = nil) ⇒ Hash
Returns a new instance of Hash.
8 9 10 |
# File 'lib/yamload/defaults/hash.rb', line 8 def initialize(defaults = nil) self.defaults = defaults end |
Instance Attribute Details
#defaults ⇒ Object
Returns the value of attribute defaults.
6 7 8 |
# File 'lib/yamload/defaults/hash.rb', line 6 def defaults @defaults end |
Instance Method Details
#merge(hash) ⇒ Object
19 20 21 22 23 |
# File 'lib/yamload/defaults/hash.rb', line 19 def merge(hash) return hash if @defaults.nil? fail ArgumentError, "#{hash} is not a hash" unless hash.is_a?(::Hash) @defaults.deep_merge(hash) end |