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