Sha256: b5f8296cea7c038c59214e2a38d53151c335e69392498d3a8c3360c7bdcceae9

Contents?: true

Size: 1.39 KB

Versions: 99

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

99 entries across 99 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/parser/ast/collection.rb
puppet-parse-0.1.3 lib/vendor/puppet/parser/ast/collection.rb
puppet-parse-0.1.2 lib/vendor/puppet/parser/ast/collection.rb
puppet-parse-0.1.1 lib/vendor/puppet/parser/ast/collection.rb
puppet-2.7.26 lib/puppet/parser/ast/collection.rb
puppet-3.6.2 lib/puppet/parser/ast/collection.rb
puppet-3.6.2-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.6.1 lib/puppet/parser/ast/collection.rb
puppet-3.6.1-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.6.0 lib/puppet/parser/ast/collection.rb
puppet-3.6.0-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.6.0.rc1 lib/puppet/parser/ast/collection.rb
puppet-3.6.0.rc1-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.5.1 lib/puppet/parser/ast/collection.rb
puppet-3.5.1-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.5.1.rc1 lib/puppet/parser/ast/collection.rb
puppet-3.5.1.rc1-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.5.0.rc3 lib/puppet/parser/ast/collection.rb
puppet-3.5.0.rc3-x86-mingw32 lib/puppet/parser/ast/collection.rb
puppet-3.5.0.rc2 lib/puppet/parser/ast/collection.rb