Class: Puppet::Parser::Methods::Method
- Defined in:
- lib/puppet/parser/methods.rb
Overview
Represents an invokable method configured to be invoked for a given object.
Instance Method Summary collapse
-
#initialize(receiver, obj, method_name, rvalue) ⇒ Method
constructor
A new instance of Method.
-
#invoke(scope, args = [], pblock = nil) ⇒ Object
Invoke this method’s function in the given scope with the given arguments and parameterized block.
-
#is_rvalue? ⇒ Boolean
Whether the method function produces an rvalue or not.
Constructor Details
#initialize(receiver, obj, method_name, rvalue) ⇒ Method
Returns a new instance of Method.
24 25 26 27 28 29 |
# File 'lib/puppet/parser/methods.rb', line 24 def initialize(receiver, obj, method_name, rvalue) @receiver = receiver @o = obj @method_name = method_name @rvalue = rvalue end |
Instance Method Details
#invoke(scope, args = [], pblock = nil) ⇒ Object
Invoke this method’s function in the given scope with the given arguments and parameterized block. A method call on the form:
$a.meth(1,2,3) {|...| ...}
results in the equivalent:
meth($a, 1, 2, 3, {|...| ... })
45 46 47 48 49 |
# File 'lib/puppet/parser/methods.rb', line 45 def invoke(scope, args=[], pblock=nil) arguments = [@o] + args arguments << pblock if pblock @receiver.send(@method_name, arguments) end |
#is_rvalue? ⇒ Boolean
Returns whether the method function produces an rvalue or not.
52 53 54 |
# File 'lib/puppet/parser/methods.rb', line 52 def is_rvalue? @rvalue end |