Class: Puppet::Parser::Methods::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/parser/methods.rb

Overview

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

Since:

  • 3.2

Instance Method Summary collapse

Constructor Details

#initialize(receiver, obj, method_name, rvalue) ⇒ Method

Returns a new instance of Method.

Since:

  • 3.2



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

Parameters:

Since:

  • 3.2



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.

Returns:

  • (Boolean)

    whether the method function produces an rvalue or not.

Since:

  • 3.2



52
53
54
# File 'lib/puppet/parser/methods.rb', line 52

def is_rvalue?
  @rvalue
end