Class: Declarative::Defaults

Inherits:
Object
  • Object
show all
Extended by:
Uber::Delegates
Defined in:
lib/declarative/defaults.rb

Instance Method Summary collapse

Constructor Details

#initializeDefaults

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, given_options)
  options = @static_options
  options = options.merge(dynamic_options(name, given_options))
  options = options.merge(given_options)
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