~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to lib/puppet/parser/ast/resourceoverride.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'puppet/parser/ast/resourcedef'
2
 
 
3
 
class Puppet::Parser::AST
4
 
    # Set a parameter on a resource specification created somewhere else in the
5
 
    # configuration.  The object is responsible for verifying that this is allowed.
6
 
    class ResourceOverride < ResourceDef
7
 
        attr_accessor :object
8
 
        attr_reader :params
9
 
 
10
 
        # Iterate across all of our children.
11
 
        def each
12
 
            [@object,@params].flatten.each { |param|
13
 
                #Puppet.debug("yielding param %s" % param)
14
 
                yield param
15
 
            }
16
 
        end
17
 
 
18
 
        # Does not actually return an object; instead sets an object
19
 
        # in the current scope.
20
 
        def evaluate(hash)
21
 
            scope = hash[:scope]
22
 
 
23
 
            # Get our object reference.
24
 
            object = @object.safeevaluate(:scope => scope)
25
 
 
26
 
            hash = {}
27
 
 
28
 
            # Evaluate all of the specified params.
29
 
            params = @params.collect { |param|
30
 
                param.safeevaluate(:scope => scope)
31
 
            }
32
 
 
33
 
            # Now we just create a normal resource, but we call a very different
34
 
            # method on the scope.
35
 
            obj = Puppet::Parser::Resource.new(
36
 
                :type => object.type,
37
 
                :title => object.title,
38
 
                :params => params,
39
 
                :file => @file,
40
 
                :line => @line,
41
 
                :source => scope.source,
42
 
                :scope => scope
43
 
            )
44
 
 
45
 
            # Now we tell the scope that it's an override, and it behaves as
46
 
            # necessary.
47
 
            scope.setoverride(obj)
48
 
 
49
 
            obj
50
 
        end
51
 
 
52
 
        # Create our ResourceDef.  Handles type checking for us.
53
 
        def initialize(hash)
54
 
            @checked = false
55
 
            super
56
 
 
57
 
            #self.typecheck(@type.value)
58
 
        end
59
 
    end
60
 
end
61
 
 
62
 
# $Id: resourceoverride.rb 1726 2006-10-04 18:24:24Z luke $