summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/node.rb
blob: faa7fa19a778c3fc5ebae9ba5b3b74fea9fa83f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'puppet/parser/ast/hostclass'

# The specific code associated with a host.  Nodes are annoyingly unlike
# other objects.  That's just the way it is, at least for now.
class Puppet::Parser::AST::Node < Puppet::Parser::AST::HostClass

    associates_doc

    @name = :node

    def initialize(options)
        @parentclass = nil
        super

        # Do some validation on the node name
        if @name =~ /[^-\w.]/
            raise Puppet::ParseError, "Invalid node name %s" % @name
        end
    end

    def namespace
        ""
    end

    # Make sure node scopes are marked as such.
    def subscope(*args)
        scope = super
        scope.nodescope = true
        scope
    end

    private

    # Search for the object matching our parent class.
    def find_parentclass
        @parser.node(parentclass)
    end
end