Class: Puppet::Pops::Evaluator::Closure::Dynamic

Inherits:
Puppet::Pops::Evaluator::Closure show all
Defined in:
lib/puppet/pops/evaluator/closure.rb

Constant Summary

Constants inherited from Puppet::Pops::Evaluator::Closure

CLOSURE_NAME

Instance Attribute Summary

Attributes inherited from Puppet::Pops::Evaluator::Closure

#evaluator, #model

Instance Method Summary collapse

Methods inherited from Puppet::Pops::Evaluator::Closure

#block_name, #call_by_name, #call_by_name_with_scope, #closure_name, #invoke, #last_captures_rest?, #parameter_count, #parameter_names, #parameters, #params_struct, #return_type, #type

Methods inherited from Puppet::Pops::Evaluator::CallableSignature

#args_range, #argument_mismatch_handler?, #block_name, #block_range, #block_type, #infinity?, #last_captures_rest?, #parameter_names, #type

Constructor Details

#initialize(evaluator, model, scope) ⇒ Dynamic

Returns a new instance of Dynamic.



171
172
173
174
# File 'lib/puppet/pops/evaluator/closure.rb', line 171

def initialize(evaluator, model, scope)
  @enclosing_scope = scope
  super(evaluator, model)
end

Instance Method Details

#call(*args) ⇒ Object



180
181
182
183
184
185
186
187
188
# File 'lib/puppet/pops/evaluator/closure.rb', line 180

def call(*args)
  # A return from an unnamed closure is treated as a return from the context evaluating
  # calling this closure - that is, as if it was the return call itself.
  #
  jumper = catch(:return) do
    return call_with_scope(enclosing_scope, args)
  end
  raise jumper
end

#enclosing_scopeObject



176
177
178
# File 'lib/puppet/pops/evaluator/closure.rb', line 176

def enclosing_scope
  @enclosing_scope
end