Class: Puppet::Parser::AST::PopsBridge::Expression
- Inherits:
-
Leaf
- Object
- Puppet::Parser::AST
- Leaf
- Puppet::Parser::AST::PopsBridge::Expression
- Defined in:
- lib/puppet/parser/ast/pops_bridge.rb
Overview
Bridges to one Pops Model Expression The @value is the expression This is used to represent the body of a class, definition, or node, and for each parameter’s default value expression.
Direct Known Subclasses
Constant Summary
Constants inherited from Puppet::Parser::AST
Instance Attribute Summary
Attributes inherited from Leaf
Attributes inherited from Puppet::Parser::AST
#file, #line, #parent, #pos, #scope
Instance Method Summary collapse
-
#children ⇒ Object
The 3x requires code plugged in to an AST to have this in certain positions in the tree.
-
#each {|_self| ... } ⇒ Object
Adapts to 3x where top level constructs needs to have each to iterate over children.
- #evaluate(scope) ⇒ Object
- #sequence_with(other) ⇒ Object
- #source_text ⇒ Object
- #to_s ⇒ Object
Methods inherited from Leaf
Methods inherited from Puppet::Parser::AST
#initialize, #inspect, #safeevaluate
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail
Constructor Details
This class inherits a constructor from Puppet::Parser::AST::Leaf
Instance Method Details
#children ⇒ Object
The 3x requires code plugged in to an AST to have this in certain positions in the tree. The purpose is to either print the content, or to look for things that needs to be defined. This implementation cheats by always returning an empty array. (This allows simple files to not require a “Program” at the top.
55 56 57 |
# File 'lib/puppet/parser/ast/pops_bridge.rb', line 55 def children [] end |
#each {|_self| ... } ⇒ Object
Adapts to 3x where top level constructs needs to have each to iterate over children. Short circuit this by yielding self. By adding this there is no need to wrap a pops expression inside an AST::BlockExpression
35 36 37 |
# File 'lib/puppet/parser/ast/pops_bridge.rb', line 35 def each yield self end |
#evaluate(scope) ⇒ Object
26 27 28 29 30 |
# File 'lib/puppet/parser/ast/pops_bridge.rb', line 26 def evaluate(scope) evaluator = Puppet::Pops::Parser::EvaluatingParser.singleton object = evaluator.evaluate(scope, @value) evaluator.convert_to_3x(object, scope) end |
#sequence_with(other) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/puppet/parser/ast/pops_bridge.rb', line 39 def sequence_with(other) if value.nil? # This happens when testing and not having a complete setup other else # When does this happen ? Ever ? raise "sequence_with called on Puppet::Parser::AST::PopsBridge::Expression - please report use case" # What should be done if the above happens (We don't want this to happen). # Puppet::Parser::AST::BlockExpression.new(:children => [self] + other.children) end end |