class Puppet::Parser::Methods::Method

Represents an invokable method configured to be invoked for a given object.

Public Instance Methods

invoke(scope, args=[], pblock=nil) click to toggle source

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, {|...| ... })

@param scope [Puppet::Parser::Scope] the scope the call takes place in @param args [Array<Object>] arguments 1..n to pass to the function @param pblock [Puppet::Parser::AST::Lambda] optional parameterized block to pass as the last argument

to the called function
# 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?() click to toggle source

@return [Boolean] whether the method function produces an rvalue or not.

# File lib/puppet/parser/methods.rb, line 52
def is_rvalue?
  @rvalue
end

Public Class Methods

new(receiver, obj, method_name, rvalue) click to toggle source
# 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