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



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

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

Instance Method Details

#closure_nameObject



197
198
199
# File 'lib/puppet/pops/evaluator/closure.rb', line 197

def closure_name
  @name
end

#enclosing_scopeObject

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



203
204
205
206
207
208
209
210
211
# File 'lib/puppet/pops/evaluator/closure.rb', line 203

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