Sha256: fca028c7271649f65629165d5307e59abfd73a0e1045387bf38f5dad349249eb

Contents?: true

Size: 1.72 KB

Versions: 44

Compression:

Stored size: 1.72 KB

Contents

require 'puppet/parser/ast/resource'

class Puppet::Parser::AST
  # Set a parameter on a resource specification created somewhere else in the
  # configuration.  The object is responsible for verifying that this is allowed.
  class ResourceOverride < AST::Branch

    associates_doc

    attr_accessor :object, :parameters

    # Iterate across all of our children.
    def each
      [@object,@parameters].flatten.each { |param|
        #Puppet.debug("yielding param #{param}")
        yield param
      }
    end

    # Does not actually return an object; instead sets an object
    # in the current scope.
    def evaluate(scope)
      # Get our object reference.
      resource = @object.safeevaluate(scope)

      hash = {}

      # Evaluate all of the specified params.
      params = @parameters.collect { |param|
        param.safeevaluate(scope)
      }

      # Now we just create a normal resource, but we call a very different
      # method on the scope.
      resource = [resource] unless resource.is_a?(Array)

      resource = resource.collect do |r|

              res = Puppet::Parser::Resource.new(
        r.type, r.title,
          :parameters => params,
          :file => file,
          :line => line,
          :source => scope.source,
        
          :scope => scope
        )

        # Now we tell the scope that it's an override, and it behaves as
        # necessary.
        scope.compiler.add_override(res)

        res
      end
      # decapsulate array in case of only one item
      return(resource.length == 1 ? resource.pop : resource)
    end

    # Create our ResourceDef.  Handles type checking for us.
    def initialize(hash)
      @checked = false
      super

      #self.typecheck(@type.value)
    end
  end
end

Version data entries

44 entries across 44 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-parse-0.1.3 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-parse-0.1.2 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-parse-0.1.1 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-2.7.26 lib/puppet/parser/ast/resource_override.rb
puppet-2.7.25 lib/puppet/parser/ast/resource_override.rb
puppet-2.7.24 lib/puppet/parser/ast/resource_override.rb
puppet-2.7.23 lib/puppet/parser/ast/resource_override.rb
puppet-2.7.22 lib/puppet/parser/ast/resource_override.rb
puppet-parse-0.1.0 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-parse-0.0.6 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-2.7.21 lib/puppet/parser/ast/resource_override.rb
puppet-parse-0.0.5 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-parse-0.0.4 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-parse-0.0.2 lib/vendor/puppet/parser/ast/resource_override.rb
puppet-2.7.20 lib/puppet/parser/ast/resource_override.rb
puppet-2.7.20.rc1 lib/puppet/parser/ast/resource_override.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/parser/ast/resource_override.rb
puppet-2.7.19 lib/puppet/parser/ast/resource_override.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/parser/ast/resource_override.rb