class Puppet::Parser::AST::VarDef

Define a variable. Stores the value in the current scope.

Attributes

append[RW]
name[RW]
value[RW]

Public Instance Methods

each() { |child| ... } click to toggle source
# File lib/puppet/parser/ast/vardef.rb, line 26
def each
  [@name,@value].each { |child| yield child }
end
evaluate(scope) click to toggle source

Look up our name and value, and store them appropriately. The lexer strips off the syntax stuff like ‘$’.

# File lib/puppet/parser/ast/vardef.rb, line 13
def evaluate(scope)
  value = @value.safeevaluate(scope)
  if name.is_a?(HashOrArrayAccess)
    name.assign(scope, value)
  else
    name = @name.safeevaluate(scope)

    parsewrap do
      scope.setvar(name,value, :file => file, :line => line, :append => @append)
    end
  end
end