summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/resourceparam.rb
blob: e6d9df17f10963eb4bf90206dc20f0d09a6686a8 (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
require 'puppet/parser/ast/branch'

class Puppet::Parser::AST
    # The AST object for the parameters inside ResourceDefs and Selectors.
    class ResourceParam < AST::Branch
        attr_accessor :value, :param, :add

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

        # Return the parameter and the value.
        def evaluate(scope)
            return Puppet::Parser::Resource::Param.new(
                :name => @param,
                :value => @value.safeevaluate(scope),
                :source => scope.source, :line => self.line, :file => self.file,
                :add => self.add
            )
        end

        def to_s
            "#{@param} => #{@value.to_s}"
        end
    end
end