Class: Puppet::Parser::AST::VarDef
- Defined in:
- lib/puppet/parser/ast/vardef.rb
Overview
Define a variable. Stores the value in the current scope.
Instance Attribute Summary collapse
Attributes inherited from Branch
Instance Method Summary collapse
- #each ⇒ Object
-
#evaluate(scope) ⇒ Object
Look up our name and value, and store them appropriately.
Methods inherited from Branch
Constructor Details
This class inherits a constructor from Puppet::Parser::AST::Branch
Instance Attribute Details
Instance Method Details
#each ⇒ Object
33 34 35 |
# File 'lib/puppet/parser/ast/vardef.rb', line 33 def each [@name,@value].each { |child| yield child } end |
#evaluate(scope) ⇒ Object
Look up our name and value, and store them appropriately. The lexer strips off the syntax stuff like ‘$’.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 if @append # Produce resulting value from append operation scope[name] else # Produce assigned value value end end |