1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
require 'puppet'
require 'puppet/parser/ast/branch'
require 'puppet/parser/collector'
# An object that collects stored objects from the central cache and returns
# them to the current host, yo.
class Puppet::Parser::AST
class Collection < AST::Branch
attr_accessor :type, :query, :form
attr_reader :override
associates_doc
# We return an object that does a late-binding evaluation.
def evaluate(scope)
if self.query
str, code = self.query.safeevaluate scope
else
str = code = nil
end
newcoll = Puppet::Parser::Collector.new(scope, @type, str, code, self.form)
scope.compiler.add_collection(newcoll)
# overrides if any
# Evaluate all of the specified params.
if @override
params = @override.collect do |param|
param.safeevaluate(scope)
end
newcoll.add_override(
:parameters => params,
:file => @file,
:line => @line,
:source => scope.source,
:scope => scope
)
end
newcoll
end
# Handle our parameter ourselves
def override=(override)
if override.is_a?(AST::ASTArray)
@override = override
else
@override = AST::ASTArray.new(
:line => override.line,
:file => override.file,
:children => [override]
)
end
end
end
end
|