Class: StimulusPlumbers::Plumber::Dispatcher::InstanceExec
- Inherits:
-
Object
- Object
- StimulusPlumbers::Plumber::Dispatcher::InstanceExec
- Includes:
- CallableInspector
- Defined in:
- lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#kwargs ⇒ Object
readonly
Returns the value of attribute kwargs.
Instance Method Summary collapse
- #call(target) ⇒ Object
-
#initialize(block, *args, **kwargs) ⇒ InstanceExec
constructor
A new instance of InstanceExec.
Constructor Details
#initialize(block, *args, **kwargs) ⇒ InstanceExec
Returns a new instance of InstanceExec.
11 12 13 14 15 16 |
# File 'lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb', line 11 def initialize(block, *args, **kwargs) @block = block @args = args @kwargs = kwargs validate! end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb', line 9 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
9 10 11 |
# File 'lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb', line 9 def block @block end |
#kwargs ⇒ Object (readonly)
Returns the value of attribute kwargs.
9 10 11 |
# File 'lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb', line 9 def kwargs @kwargs end |
Instance Method Details
#call(target) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/stimulus_plumbers/plumber/dispatcher/instance_exec.rb', line 18 def call(target) dispatched = args_for(block) if accepts_kwargs?(block) target.instance_exec(*dispatched, **kwargs, &block) else target.instance_exec(*dispatched, &block) end end |