class Puppet::Pops::Evaluator::Collectors::AbstractCollector
Constants
- EMPTY_RESOURCES
An empty array which will be returned by the
unresolved_resources
method 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 25 def initialize(scope, overrides = nil) 26 @collected = {} 27 @scope = scope 28 29 if !(overrides.nil? || overrides[:parameters]) 30 raise ArgumentError, _("Exported resource try to override without parameters") 31 end 32 33 @overrides = overrides 34 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 83 def collect 84 raise NotImplementedError, "This method must be implemented by the child class" 85 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 40 def evaluate 41 objects = collect.each do |obj| 42 obj.virtual = false 43 end 44 45 return false if objects.empty? 46 47 if @overrides and !objects.empty? 48 overrides[:source].override = true 49 50 objects.each do |res| 51 unless @collected.include?(res.ref) 52 t = res.type 53 t = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, t) 54 newres = Puppet::Parser::Resource.new(t, res.title, @overrides) 55 scope.compiler.add_override(newres) 56 end 57 end 58 end 59 60 objects.reject! { |o| @collected.include?(o.ref) } 61 62 return false if objects.empty? 63 64 objects.reduce(@collected) { |c,o| c[o.ref]=o; c } 65 66 objects 67 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 74 def unresolved_resources 75 EMPTY_RESOURCES 76 end