# File lib/puppet/parser/ast/resource.rb, line 15
15:     def evaluate(scope)
16:         # Evaluate all of the specified params.
17:         paramobjects = @params.collect { |param|
18:             param.safeevaluate(scope)
19:         }
20: 
21:         resource_titles = @title.safeevaluate(scope)
22: 
23:         # it's easier to always use an array, even for only one name
24:         unless resource_titles.is_a?(Array)
25:             resource_titles = [resource_titles]
26:         end
27: 
28:         resource_type = qualified_type(scope)
29: 
30:         # We want virtual to be true if exported is true.  We can't
31:         # just set :virtual => self.virtual in the initialization,
32:         # because sometimes the :virtual attribute is set *after*
33:         # :exported, in which case it clobbers :exported if :exported
34:         # is true.  Argh, this was a very tough one to track down.
35:         virt = self.virtual || self.exported
36: 
37:         # This is where our implicit iteration takes place; if someone
38:         # passed an array as the name, then we act just like the called us
39:         # many times.
40:         resource_titles.flatten.collect { |resource_title|
41:             exceptwrap :type => Puppet::ParseError do
42:                 resource = Puppet::Parser::Resource.new(
43:                     :type => resource_type,
44:                     :title => resource_title,
45:                     :params => paramobjects,
46:                     :file => self.file,
47:                     :line => self.line,
48:                     :exported => self.exported,
49:                     :virtual => virt,
50:                     :source => scope.source,
51:                     :scope => scope
52:                 )
53: 
54:                 # And then store the resource in the compiler.
55:                 # At some point, we need to switch all of this to return
56:                 # resources instead of storing them like this.
57:                 scope.compiler.add_resource(scope, resource)
58:                 resource
59:             end
60:         }.reject { |resource| resource.nil? }
61:     end