Class: Declarative::Defaults
- Inherits:
-
Object
- Object
- Declarative::Defaults
- Extended by:
- Uber::Delegates
- Defined in:
- lib/declarative/defaults.rb
Instance Method Summary collapse
-
#call(name, given_options) ⇒ Object
TODO: allow to receive rest of options/block in dynamic block.
-
#initialize ⇒ Defaults
constructor
A new instance of Defaults.
- #merge!(hash, &block) ⇒ Object
Constructor Details
#initialize ⇒ Defaults
Returns a new instance of Defaults.
5 6 7 8 |
# File 'lib/declarative/defaults.rb', line 5 def initialize = {} = ->(*) { Hash.new } end |
Instance Method Details
#call(name, given_options) ⇒ Object
TODO: allow to receive rest of options/block in dynamic block. or, rather, test it as it was already implemented.
20 21 22 23 24 |
# File 'lib/declarative/defaults.rb', line 20 def call(name, ) = = .merge(.(name, )) = .merge() end |
#merge!(hash, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/declarative/defaults.rb', line 10 def merge!(hash, &block) .merge!(hash) if hash.any? = block if block_given? self end |