Method: Puppet::Parser::Scope::ParameterScope#evaluate3x

Defined in:
lib/puppet/parser/scope.rb

#evaluate3x(name, expression, scope) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A parameter default must be evaluated using a special scope. The scope that is given to this method must have a ‘ParameterScope` as its last ephemeral scope. This method will then push a `MatchScope` while the given `expression` is evaluated. The method will catch any throw of `:unevaluated_parameter` and produce an error saying that the evaluated parameter X tries to access the unevaluated parameter Y.

Parameters:

  • name (String)

    the name of the currently evaluated parameter

  • expression (Puppet::Parser::AST)

    the expression to evaluate

  • scope (Puppet::Parser::Scope)

    a scope where a ‘ParameterScope` has been pushed

Returns:

  • (Object)

    the result of the evaluation



189
190
191
192
193
194
195
196
197
# File 'lib/puppet/parser/scope.rb', line 189

def evaluate3x(name, expression, scope)
  scope.with_guarded_scope do
    bad = catch(:unevaluated_parameter) do
      scope.new_match_scope(nil)
      return as_read_only { expression.safeevaluate(scope) }
    end
    parameter_reference_failure(name, bad)
  end
end