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


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

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

Instance Method Details

#closure_nameObject


200
201
202
# File 'lib/puppet/pops/evaluator/closure.rb', line 200

def closure_name
  @name
end

#enclosing_scopeObject

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


206
207
208
209
210
211
212
213
214
# File 'lib/puppet/pops/evaluator/closure.rb', line 206

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