Class: Puppet::Parser::AST::VarDef
- Inherits:
-
Branch
- Object
- Puppet::Parser::AST
- Branch
- Puppet::Parser::AST::VarDef
- Defined in:
- lib/vendor/puppet/parser/ast/vardef.rb
Overview
Define a variable. Stores the value in the current scope.
Constant Summary
Constants inherited from Puppet::Parser::AST
Constants included from Util::Docs
Instance Attribute Summary collapse
-
#append ⇒ Object
Returns the value of attribute append.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Branch
Attributes inherited from Puppet::Parser::AST
Attributes included from Util::Docs
Instance Method Summary collapse
- #each ⇒ Object
-
#evaluate(scope) ⇒ Object
Look up our name and value, and store them appropriately.
Methods inherited from Branch
Methods inherited from Puppet::Parser::AST
associates_doc, #evaluate_match, #initialize, #inspect, #parsefail, #parsewrap, #safeevaluate, settor?, #use_docs
Methods included from Util::Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Methods included from Util::MethodHelper
#requiredopts, #set_options, #symbolize_options
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail
Constructor Details
This class inherits a constructor from Puppet::Parser::AST::Branch
Instance Attribute Details
#append ⇒ Object
Returns the value of attribute append.
9 10 11 |
# File 'lib/vendor/puppet/parser/ast/vardef.rb', line 9 def append @append end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/vendor/puppet/parser/ast/vardef.rb', line 9 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
9 10 11 |
# File 'lib/vendor/puppet/parser/ast/vardef.rb', line 9 def value @value end |
Instance Method Details
#each ⇒ Object
28 29 30 |
# File 'lib/vendor/puppet/parser/ast/vardef.rb', line 28 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 ‘$’.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vendor/puppet/parser/ast/vardef.rb', line 15 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 |