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, #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.



166
167
168
169
# File 'lib/puppet/pops/evaluator/closure.rb', line 166

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

Instance Method Details

#call(*args) ⇒ Object



175
176
177
178
179
180
181
182
183
# File 'lib/puppet/pops/evaluator/closure.rb', line 175

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



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

def enclosing_scope
  @enclosing_scope
end