Puppet Function: determine

Defined in:
lib/puppet/parser/functions/determine.rb
Function type:
Ruby 3.x API

Overview

determine()Any

Determine value of a macro.

This function ivokes a macro defined with ‘Puppet::Macros.newmacro` method and returns its value. The function takes macro name as first argument and macro parameters as the rest of arguments. The number of arguments provided by user is validated against macro’s arity.

Example:

Let say, you have defined the following macro in puppet/macros/sum.rb:

# puppet/macros/sum.rb
Puppet::Macros.newmacro 'sum' do |x,y|
  Integer(x) + Integer(y)
end

You may then invoke the macro from puppet as follows:

$three = determine('sum',1,2) # -> 3

Returns:

  • (Any)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet/parser/functions/determine.rb', line 5

newfunction(:determine, :type => :rvalue, :doc => <<-EOT
Determine value of a macro.

This function ivokes a macro defined with `Puppet::Macros.newmacro`
method and returns its value. The function takes macro name as first
argument and macro parameters as the rest of arguments. The number of
arguments provided by user is validated against macro's arity.

*Example*:

Let say, you have defined the following macro in
*puppet/macros/sum.rb*:

    # puppet/macros/sum.rb
    Puppet::Macros.newmacro 'sum' do |x,y|
      Integer(x) + Integer(y)
    end

You may then invoke the macro from puppet as follows:

    $three = determine('sum',1,2) # -> 3
EOT
) do |args|
  Puppet::Macros.call_macro_from_func(self,:determine,args)
end