Class: ChainOptions::Builder
- Inherits:
-
Object
- Object
- ChainOptions::Builder
- Defined in:
- lib/chain_options/builder.rb
Overview
A simple helper class to set multiple chain options after another by using a ‘set NAME, VALUE` syntax instead of having to use constructs like
instance = instance.NAME(VALUE)
instance = instance.NAME2(VALUE2) if XY
...
Instance Method Summary collapse
-
#initialize(initial_instance, &block) ⇒ Builder
constructor
A new instance of Builder.
- #result ⇒ Object
- #set(option_name, *value, &block) ⇒ Object
Constructor Details
#initialize(initial_instance, &block) ⇒ Builder
Returns a new instance of Builder.
13 14 15 16 17 |
# File 'lib/chain_options/builder.rb', line 13 def initialize(initial_instance, &block) @instance = initial_instance ChainOptions::Util.instance_eval_or_call(self, &block) result end |
Instance Method Details
#result ⇒ Object
19 20 21 |
# File 'lib/chain_options/builder.rb', line 19 def result @instance end |
#set(option_name, *value, &block) ⇒ Object
23 24 25 |
# File 'lib/chain_options/builder.rb', line 23 def set(option_name, *value, &block) @instance = @instance.send(option_name, *value, &block) end |