Class: LtdTemplate::Code::Call
- Inherits:
-
LtdTemplate::Code
- Object
- LtdTemplate::Code
- LtdTemplate::Code::Call
- Defined in:
- lib/ltdtemplate/code/call.rb
Instance Method Summary collapse
-
#evaluate(opts = {}) ⇒ Object
Return the result of executing the call.
-
#initialize(template, target, method, parameters) ⇒ Call
constructor
Initialize a method call object.
Methods inherited from LtdTemplate::Code
Constructor Details
#initialize(template, target, method, parameters) ⇒ Call
Initialize a method call object.
18 19 20 21 |
# File 'lib/ltdtemplate/code/call.rb', line 18 def initialize (template, target, method, parameters) super template @target, @method, @parameters = target, method, parameters end |
Instance Method Details
#evaluate(opts = {}) ⇒ Object
Return the result of executing the call.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ltdtemplate/code/call.rb', line 27 def evaluate (opts = {}) # Increase the call count and call depth. # RESOURCE calls: Total number of method calls @template.use :calls # RESOURCE call_depth: The current method call depth @template.use :call_depth # Invoke the method call that we encode against the target. result = rubyversed(@target).evaluate({ :method => @method, :parameters => rubyversed(@parameters).evaluate }) # Decrease the call depth. @template.use :call_depth, -1 # Invoke the method call requested by our invoker against the result. result = rubyversed(result).evaluate({ :method => opts[:method], :parameters => opts[:parameters] }) if opts[:method] result end |