evaluator for Ruby
if object is an Class or Module then define instance method to it, else define singleton method to it.
# File lib/erubis/evaluator.rb, line 79
79: def def_method(object, method_name, filename=nil)
80: m = object.is_a?(Module) ? :module_eval : :instance_eval
81: object.__send__(m, "def #{method_name}; #{@src}; end", filename || @filename || '(erubis)')
82: end
invoke context.instance_eval(@src)
# File lib/erubis/evaluator.rb, line 69
69: def evaluate(_context=Context.new)
70: _context = Context.new(_context) if _context.is_a?(Hash)
71: #return _context.instance_eval(@src, @filename || '(erubis)')
72: #@_proc ||= eval("proc { #{@src} }", Erubis::EMPTY_BINDING, @filename || '(erubis)')
73: @_proc ||= eval("proc { #{@src} }", binding(), @filename || '(erubis)')
74: return _context.instance_eval(&@_proc)
75: end
eval(@src) with binding object
# File lib/erubis/evaluator.rb, line 53
53: def result(_binding_or_hash=TOPLEVEL_BINDING)
54: _arg = _binding_or_hash
55: if _arg.is_a?(Hash)
56: _b = binding()
57: eval _arg.collect{|k,v| "#{k} = _arg[#{k.inspect}]; "}.join, _b
58: elsif _arg.is_a?(Binding)
59: _b = _arg
60: elsif _arg.nil?
61: _b = binding()
62: else
63: raise ArgumentError.new("#{self.class.name}#result(): argument should be Binding or Hash but passed #{_arg.class.name} object.")
64: end
65: return eval(@src, _b, (@filename || '(erubis'))
66: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.