Class: Puppet::Pops::Evaluator::Closure::Named

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, #call_by_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(name, evaluator, model) ⇒ Named

Returns a new instance of Named.



187
188
189
190
# File 'lib/puppet/pops/evaluator/closure.rb', line 187

def initialize(name, evaluator, model)
  @name = name
  super(evaluator, model)
end

Instance Method Details

#closure_nameObject



192
193
194
# File 'lib/puppet/pops/evaluator/closure.rb', line 192

def closure_name
  @name
end

#enclosing_scopeObject

The assigned enclosing scope, or global scope if enclosing scope was initialized to nil



198
199
200
201
202
203
204
205
206
# File 'lib/puppet/pops/evaluator/closure.rb', line 198

def enclosing_scope
  # Named closures are typically used for puppet functions and they cannot be defined
  # in an enclosing scope as they are cashed and reused. They need to bind to the
  # global scope at time of use rather at time of definition.
  # Unnamed closures are always a runtime construct, they are never bound by a loader
  # and are thus garbage collected at end of a compilation.
  #
  Puppet.lookup(:global_scope) { {} }
end