class LtdTemplate::Code::Call
Public Class Methods
new(template, target, method, parameters)
click to toggle source
Initialize a method call object.
@param template [LtdTemplate] The template object @param target (Code for) the target to call @param method [String] The method to invoke @param parameters [LtdTemplate::Code::Parameters] Code blocks for
the method parameters
Calls superclass method
LtdTemplate::Code::new
# File lib/ltdtemplate/code/call.rb, line 18 def initialize (template, target, method, parameters) super template @target, @method, @parameters = target, method, parameters end
Public Instance Methods
evaluate(opts = {})
click to toggle source
Return the result of executing the call.
@param opts [Hash] Option hash @option opts [String] :method A method to call on the return value
# 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