Module: Eco::Language::Methods::DslAble
- Defined in:
- lib/eco/language/methods/dsl_able.rb
Instance Method Summary collapse
-
#evaluate(*args, **kargs, &block) ⇒ Object
It runs the
block
within this object context. -
#method_missing(method, *args, **kargs, &block) ⇒ Object
When it's the case, redirect to the original
evaluate
caller.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, **kargs, &block) ⇒ Object
When it's the case, redirect to the original evaluate
caller
18 19 20 21 |
# File 'lib/eco/language/methods/dsl_able.rb', line 18 def method_missing(method, *args, **kargs, &block) super unless @self_before_evaluate @self_before_evaluate.send(method, *args, **kargs, &block) end |
Instance Method Details
#evaluate(*args, **kargs, &block) ⇒ Object
Note:
if the object misses any method, redirects the method to the original evaluate caller.
It runs the block
within this object context
8 9 10 11 12 13 14 |
# File 'lib/eco/language/methods/dsl_able.rb', line 8 def evaluate(*args, **kargs, &block) return unless block_given? @self_before_evaluate = eval "self", block.binding instance_exec(*args, **kargs, &block).tap do @self_before_evaluate = nil end end |