summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/objectparam.rb
blob: 87c3e5e8e94c7144a2916aa92bba6aa13e25b266 (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
class Puppet::Parser::AST
    # The AST object for the parameters inside ObjectDefs and Selectors.
    class ObjectParam < AST::Branch
        attr_accessor :value, :param

        def each
            [@param,@value].each { |child| yield child }
        end

        # Return the parameter and the value.
        def evaluate(hash)
            scope = hash[:scope]
            param = @param.safeevaluate(:scope => scope)
            value = @value.safeevaluate(:scope => scope)
            return [param, value]
        end

        def tree(indent = 0)
            return [
                @param.tree(indent + 1),
                ((@@indline * indent) + self.typewrap(self.pin)),
                @value.tree(indent + 1)
            ].join("\n")
        end

        def to_s
            return "%s => %s" % [@param,@value]
        end
    end

end