Sha256: beaedbf9c221e287cae6d29f90f305a78edad85eec152f19249419b3ce5edcb5

Contents?: true

Size: 1.06 KB

Versions: 20

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

class Puppet::Pops::Evaluator::Collectors::FixedSetCollector < Puppet::Pops::Evaluator::Collectors::AbstractCollector
  # 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.
  #
  # @param [Array] resources the fixed set of resources we want to realize
  def initialize(scope, resources)
    super(scope)
    @resources = resources.is_a?(Array) ? resources.dup : [resources]
  end

  # Collects a fixed set of resources and realizes them. Used
  # by the realize function
  def collect
    resolved = []
    result = @resources.each_with_object([]) do |ref, memo|
      res = @scope.findresource(ref.to_s)
      next unless res

      res.virtual = false
      memo << res
      resolved << ref
    end

    @resources -= resolved

    @scope.compiler.delete_collection(self) if @resources.empty?

    result
  end

  def unresolved_resources
    @resources
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.10.0-x86-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.10.0-x64-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.10.0-universal-darwin lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.9.0 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.9.0-x86-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.9.0-x64-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.9.0-universal-darwin lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.8.1 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.8.1-x86-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.8.1-x64-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.8.1-universal-darwin lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.7.0 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.7.0-x86-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.7.0-x64-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.7.0-universal-darwin lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.6.0 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.6.0-x86-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.6.0-x64-mingw32 lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb
puppet-8.6.0-universal-darwin lib/puppet/pops/evaluator/collectors/fixed_set_collector.rb