Class: Puppet::Parser::AST::ResourceReference
- Inherits:
-
Branch
show all
- Defined in:
- lib/puppet/parser/ast/resource_reference.rb
Instance Attribute Summary collapse
Attributes inherited from Branch
#children, #pin
Instance Method Summary
collapse
Methods inherited from Branch
#each, #initialize
Instance Attribute Details
5
6
7
|
# File 'lib/puppet/parser/ast/resource_reference.rb', line 5
def title
@title
end
|
5
6
7
|
# File 'lib/puppet/parser/ast/resource_reference.rb', line 5
def type
@type
end
|
Instance Method Details
#evaluate(scope) ⇒ Object
Evaluate our object, but just return a simple array of the type and name.
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/puppet/parser/ast/resource_reference.rb', line 9
def evaluate(scope)
titles = Array(title.safeevaluate(scope)).flatten
a_type, titles = scope.resolve_type_and_titles(type, titles)
resources = titles.collect{ |a_title|
Puppet::Resource.new(a_type, a_title)
}
return(resources.length == 1 ? resources.pop : resources)
end
|
21
22
23
24
25
26
27
|
# File 'lib/puppet/parser/ast/resource_reference.rb', line 21
def to_s
if title.is_a?(Puppet::Parser::AST::ASTArray)
"#{type.to_s.capitalize}#{title}"
else
"#{type.to_s.capitalize}[#{title}]"
end
end
|