Sha256: 768da1efe4d7e315c6ee0e29eaa761d9ce9870c479d4d1ee7c96d45db081528a

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

class Puppet::Parser::AST
    # Define a variable.  Stores the value in the current scope.
    class VarDef < AST::Branch
        attr_accessor :name, :value

        # Look up our name and value, and store them appropriately.  The
        # lexer strips off the syntax stuff like '$'.
        def evaluate(hash)
            scope = hash[:scope]
            name = @name.safeevaluate(:scope => scope)
            value = @value.safeevaluate(:scope => scope)

            begin
                scope.setvar(name,value)
            rescue Puppet::ParseError => except
                except.line = self.line
                except.file = self.file
                raise except
            rescue => detail
                error = Puppet::ParseError.new(detail)
                error.line = self.line
                error.file = self.file
                error.backtrace = detail.backtrace
                raise error
            end
        end

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

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

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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-0.13.6 lib/puppet/parser/ast/vardef.rb
puppet-0.18.4 lib/puppet/parser/ast/vardef.rb
puppet-0.16.0 lib/puppet/parser/ast/vardef.rb