summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/astarray.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/ast/astarray.rb')
-rw-r--r--lib/puppet/parser/ast/astarray.rb35
1 files changed, 12 insertions, 23 deletions
diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb
index 529998e3c..7283a1f6c 100644
--- a/lib/puppet/parser/ast/astarray.rb
+++ b/lib/puppet/parser/ast/astarray.rb
@@ -16,25 +16,20 @@ class Puppet::Parser::AST
# Evaluate our children.
def evaluate(scope)
- # Make a new array, so we don't have to deal with the details of
- # flattening and such
- items = []
-
- # First clean out any AST::ASTArrays
- @children.each { |child|
- if child.instance_of?(AST::ASTArray)
- child.each do |ac|
- items << ac
+ result = []
+ @children.each do |child|
+ # Skip things that respond to :instantiate (classes, nodes,
+ # and definitions), because they have already been
+ # instantiated.
+ if !child.respond_to?(:instantiate)
+ item = child.safeevaluate(scope)
+ if !item.nil?
+ # nil values are implicitly removed.
+ result.push(item)
end
- else
- items << child
end
- }
-
- rets = items.flatten.collect { |child|
- child.safeevaluate(scope)
- }
- rets.reject { |o| o.nil? }
+ end
+ result
end
def push(*ary)
@@ -52,10 +47,4 @@ class Puppet::Parser::AST
"[" + @children.collect { |c| c.to_s }.join(', ') + "]"
end
end
-
- # A simple container class, containing the parameters for an object.
- # Used for abstracting the grammar declarations. Basically unnecessary
- # except that I kept finding bugs because I had too many arrays that
- # meant completely different things.
- class ResourceInstance < ASTArray; end
end