An object that collects stored objects from the central cache and returns them to the current host, yo.
| AST | = | Puppet::Parser::AST | Do this so I don‘t have to type the full path in all of the subclasses |
| file | [RW] | |
| line | [RW] | |
| parent | [RW] | |
| scope | [RW] |
Initialize the object. Requires a hash as the argument, and takes each of the parameters of the hash and calls the settor method for them. This is probably pretty inefficient and should likely be changed at some point.
# File lib/puppet/parser/ast.rb, line 69
69: def initialize(args)
70: @file = nil
71: @line = nil
72: set_options(args)
73: end
Does this ast object set something? If so, it gets evaluated first.
# File lib/puppet/parser/ast.rb, line 18
18: def self.settor?
19: if defined? @settor
20: @settor
21: else
22: false
23: end
24: end
Evaluate the current object. Just a stub method, since the subclass should override this method. of the contained children and evaluates them in turn, returning a list of all of the collected values, rejecting nil values
# File lib/puppet/parser/ast.rb, line 30
30: def evaluate(*options)
31: raise Puppet::DevError, "Did not override #evaluate in %s" % self.class
32: end
Throw a parse error.
# File lib/puppet/parser/ast.rb, line 35
35: def parsefail(message)
36: self.fail(Puppet::ParseError, message)
37: end
Wrap a statemp in a reusable way so we always throw a parse error.
# File lib/puppet/parser/ast.rb, line 40
40: def parsewrap
41: exceptwrap :type => Puppet::ParseError do
42: yield
43: end
44: end
The version of the evaluate method that should be called, because it correctly handles errors. It is critical to use this method because it can enable you to catch the error where it happens, rather than much higher up the stack.
# File lib/puppet/parser/ast.rb, line 50
50: def safeevaluate(*options)
51: # We duplicate code here, rather than using exceptwrap, because this
52: # is called so many times during parsing.
53: begin
54: return self.evaluate(*options)
55: rescue Puppet::Error => detail
56: raise adderrorcontext(detail)
57: rescue => detail
58: error = Puppet::Error.new(detail.to_s)
59: # We can't use self.fail here because it always expects strings,
60: # not exceptions.
61: raise adderrorcontext(error, detail)
62: end
63: end