Sha256: 2e5e1d492edce9848388fd983608520a7814d8f545d9fe5a8ebe5c694670661e

Contents?: true

Size: 1.47 KB

Versions: 50

Compression:

Stored size: 1.47 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)
      match, code = query && query.safeevaluate(scope)

      if @type == 'class'
        fail "Classes cannot be collected"
      end

      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, match, 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

50 entries across 50 versions & 2 rubygems

Version Path
puppet-retrospec-0.12.2 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb
puppet-3.8.7 lib/puppet/parser/ast/collection.rb
puppet-3.8.7-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.8.7-x64-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.8.6 lib/puppet/parser/ast/collection.rb
puppet-3.8.6-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb
puppet-3.8.6-x64-mingw32 lib/puppet/parser/ast/collection.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb
puppet-3.8.5 lib/puppet/parser/ast/collection.rb
puppet-3.8.5-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.8.5-x64-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.8.4 lib/puppet/parser/ast/collection.rb
puppet-3.8.4-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.8.4-x64-mingw32 lib/puppet/parser/ast/collection.rb
puppet-retrospec-0.11.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb
puppet-retrospec-0.10.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/collection.rb