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 |
# File 'lib/declarative/defaults.rb', line 5 def initialize @static_options = {} 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.
19 20 21 22 23 |
# File 'lib/declarative/defaults.rb', line 19 def call(name, ) = @static_options = .merge((name, )) = .merge() end |
#merge!(hash, &block) ⇒ Object
9 10 11 12 13 |
# File 'lib/declarative/defaults.rb', line 9 def merge!(hash, &block) @static_options.merge!(hash) if hash.any? @dynamic_options = block if block_given? self end |