Sha256: 3f6b5ce129377b1333e1f2255836a6efc5c7d5fea79c7c530e531f5eee08ffc8

Contents?: true

Size: 1.39 KB

Versions: 14

Compression:

Stored size: 1.39 KB

Contents

require 'puppet'
require 'puppet/parser/ast/branch'
require 'puppet/parser/collector'

# An object that collects stored objects from the central cache and returns
# them to the current host, yo.
class Puppet::Parser::AST
  class Collection < AST::Branch
    attr_accessor :type, :query, :form
    attr_reader :override

    associates_doc

    # We return an object that does a late-binding evaluation.
    def evaluate(scope)
      str, code = query && query.safeevaluate(scope)

      resource_type = scope.find_resource_type(@type)
      fail "Resource type #{@type} doesn't exist" unless resource_type
      newcoll = Puppet::Parser::Collector.new(scope, resource_type.name, str, code, self.form)

      scope.compiler.add_collection(newcoll)

      # overrides if any
      # Evaluate all of the specified params.
      if @override
        params = @override.collect { |param| param.safeevaluate(scope) }
        newcoll.add_override(
          :parameters => params,
          :file       => @file,
          :line       => @line,
          :source     => scope.source,
          :scope      => scope
        )
      end

      newcoll
    end

    # Handle our parameter ourselves
    def override=(override)
      @override = if override.is_a?(AST::ASTArray)
        override
      else
        AST::ASTArray.new(:line => override.line,:file => override.file,:children => [override])
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
puppet-2.6.18 lib/puppet/parser/ast/collection.rb
puppet-2.6.17 lib/puppet/parser/ast/collection.rb
puppet-2.6.16 lib/puppet/parser/ast/collection.rb
puppet-2.6.15 lib/puppet/parser/ast/collection.rb
puppet-2.6.14 lib/puppet/parser/ast/collection.rb
puppet-2.6.13 lib/puppet/parser/ast/collection.rb
puppet-2.6.12 lib/puppet/parser/ast/collection.rb
puppet-2.6.11 lib/puppet/parser/ast/collection.rb
puppet-2.6.10 lib/puppet/parser/ast/collection.rb
puppet-2.7.3 lib/puppet/parser/ast/collection.rb
puppet-2.7.1 lib/puppet/parser/ast/collection.rb
puppet-2.6.9 lib/puppet/parser/ast/collection.rb
puppet-2.6.8 lib/puppet/parser/ast/collection.rb
puppet-2.6.7 lib/puppet/parser/ast/collection.rb