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

Inherits:
Closure
  • Object
show all
Defined in:
lib/puppet/pops/evaluator/closure.rb

Instance Method Summary collapse

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