Class: Puppet::Pops::Evaluator::Collectors::FixedSetCollector
- Inherits:
-
AbstractCollector
- Object
- AbstractCollector
- Puppet::Pops::Evaluator::Collectors::FixedSetCollector
- Defined in:
- lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
Constant Summary
Constants inherited from AbstractCollector
AbstractCollector::EMPTY_RESOURCES
Instance Attribute Summary
Attributes inherited from AbstractCollector
#collected, #overrides, #scope
Instance Method Summary collapse
-
#collect ⇒ Object
Collects a fixed set of resources and realizes them.
-
#initialize(scope, resources) ⇒ FixedSetCollector
constructor
Creates a FixedSetCollector using the AbstractCollector constructor to set the scope.
- #unresolved_resources ⇒ Object
Methods inherited from AbstractCollector
Constructor Details
#initialize(scope, resources) ⇒ FixedSetCollector
Creates a FixedSetCollector using the AbstractCollector constructor to set the scope. It is not possible for a collection to have overrides in this case, since we have a fixed set of resources that can be different types.
9 10 11 12 |
# File 'lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb', line 9 def initialize(scope, resources) super(scope) @resources = resources.is_a?(Array)? resources.dup : [resources] end |
Instance Method Details
#collect ⇒ Object
Collects a fixed set of resources and realizes them. Used by the realize function
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb', line 16 def collect resolved = [] result = @resources.reduce([]) do |memo, ref| if res = @scope.findresource(ref.to_s) res.virtual = false memo << res resolved << ref end memo end @resources = @resources - resolved @scope.compiler.delete_collection(self) if @resources.empty? result end |
#unresolved_resources ⇒ Object
34 35 36 |
# File 'lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb', line 34 def unresolved_resources @resources end |