class Puppet::Parser::AST::PopsBridge::Expression
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.
Public Instance Methods
children()
click to toggle source
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.
# File lib/puppet/parser/ast/pops_bridge.rb 54 def children 55 [] 56 end
each() { |self| ... }
click to toggle source
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
# File lib/puppet/parser/ast/pops_bridge.rb 34 def each 35 yield self 36 end
evaluate(scope)
click to toggle source
# File lib/puppet/parser/ast/pops_bridge.rb 25 def evaluate(scope) 26 evaluator = Puppet::Pops::Parser::EvaluatingParser.singleton 27 object = evaluator.evaluate(scope, @value) 28 evaluator.convert_to_3x(object, scope) 29 end
sequence_with(other)
click to toggle source
# File lib/puppet/parser/ast/pops_bridge.rb 38 def sequence_with(other) 39 if value.nil? 40 # This happens when testing and not having a complete setup 41 other 42 else 43 # When does this happen ? Ever ? 44 raise "sequence_with called on Puppet::Parser::AST::PopsBridge::Expression - please report use case" 45 # What should be done if the above happens (We don't want this to happen). 46 # Puppet::Parser::AST::BlockExpression.new(:children => [self] + other.children) 47 end 48 end
source_text()
click to toggle source
# File lib/puppet/parser/ast/pops_bridge.rb 20 def source_text 21 source_adapter = Puppet::Pops::Utils.find_closest_positioned(@value) 22 source_adapter ? source_adapter.extract_text() : nil 23 end
to_s()
click to toggle source
# File lib/puppet/parser/ast/pops_bridge.rb 16 def to_s 17 Puppet::Pops::Model::ModelTreeDumper.new.dump(@value) 18 end