class Puppet::Parser::AST::ResourceOverride

Set a parameter on a resource specification created somewhere else in the configuration. The object is responsible for verifying that this is allowed.

Attributes

object[RW]
parameters[RW]

Public Class Methods

new(hash) click to toggle source

Create our ResourceDef. Handles type checking for us.

Calls superclass method
# File lib/puppet/parser/ast/resource_override.rb, line 59
def initialize(hash)
  @checked = false
  super
end

Public Instance Methods

each() { |param| ... } click to toggle source

Iterate across all of our children.

# File lib/puppet/parser/ast/resource_override.rb, line 13
def each
  [@object,@parameters].flatten.each { |param|
    #Puppet.debug("yielding param #{param}")
    yield param
  }
end
evaluate(scope) click to toggle source

Does not actually return an object; instead sets an object in the current scope.

# File lib/puppet/parser/ast/resource_override.rb, line 22
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