class Puppet::Pops::Evaluator::Collectors::AbstractCollector
Constants
- EMPTY_RESOURCES
An empty array which will be returned by the
unresolved_resourcesmethod unless we have a FixSetCollector
Attributes
The set of collected resources
The collector's hash of overrides {:parameters => params}
Public Class Methods
Initialized the instance variables needed by the base collector class to perform evaluation
@param [Puppet::Parser::Scope] scope
@param [Hash] overrides a hash of optional overrides @options opts [Array] :parameters @options opts [String] :file @options opts [Array] :line @options opts [Puppet::Resource::Type] :source @options opts [Puppet::Parser::Scope] :scope
# File lib/puppet/pops/evaluator/collectors/abstract_collector.rb 26 def initialize(scope, overrides = nil) 27 @collected = {} 28 @scope = scope 29 30 if !(overrides.nil? || overrides[:parameters]) 31 raise ArgumentError, _("Exported resource try to override without parameters") 32 end 33 34 @overrides = overrides 35 end
Public Instance Methods
Collect the specified resources. The way this is done depends on which type of collector we are dealing with. This method is implemented differently in each of the three child classes
@return [Array] the collected resources
# File lib/puppet/pops/evaluator/collectors/abstract_collector.rb 84 def collect 85 raise NotImplementedError, "This method must be implemented by the child class" 86 end
Collects resources and marks collected objects as non-virtual. Also handles overrides.
@return [Array] the resources we have collected
# File lib/puppet/pops/evaluator/collectors/abstract_collector.rb 41 def evaluate 42 objects = collect.each do |obj| 43 obj.virtual = false 44 end 45 46 return false if objects.empty? 47 48 if @overrides and !objects.empty? 49 overrides[:source].override = true 50 51 objects.each do |res| 52 unless @collected.include?(res.ref) 53 t = res.type 54 t = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, t) 55 newres = Puppet::Parser::Resource.new(t, res.title, @overrides) 56 scope.compiler.add_override(newres) 57 end 58 end 59 end 60 61 objects.reject! { |o| @collected.include?(o.ref) } 62 63 return false if objects.empty? 64 65 objects.reduce(@collected) { |c,o| c[o.ref]=o; c } 66 67 objects 68 end
This should only return an empty array unless we have an FixedSetCollector, in which case it will return the resources that have not yet been realized
@return [Array] the resources that have not been resolved
# File lib/puppet/pops/evaluator/collectors/abstract_collector.rb 75 def unresolved_resources 76 EMPTY_RESOURCES 77 end