Class: Pact::DslDelegator
- Inherits:
-
Object
- Object
- Pact::DslDelegator
- Defined in:
- lib/pact/shared/dsl.rb
Instance Method Summary collapse
-
#initialize(delegation_target) ⇒ DslDelegator
constructor
A new instance of DslDelegator.
- #instance_eval_with_previous_context_available(*args, &block) ⇒ Object
Constructor Details
#initialize(delegation_target) ⇒ DslDelegator
Returns a new instance of DslDelegator.
5 6 7 |
# File 'lib/pact/shared/dsl.rb', line 5 def initialize delegation_target @delegation_target = delegation_target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (protected)
17 18 19 20 21 22 23 |
# File 'lib/pact/shared/dsl.rb', line 17 def method_missing(method, *args, &block) if delegation_target_responds_to? method delegation_target.send(method, *args, &block) else previous_context.send(method, *args, &block) end end |
Instance Method Details
#instance_eval_with_previous_context_available(*args, &block) ⇒ Object
9 10 11 12 13 |
# File 'lib/pact/shared/dsl.rb', line 9 def instance_eval_with_previous_context_available(*args, &block) with_previous_context_available(block.binding) do bind_block_as_instance_method_on_self(&block).call(*args) end end |