# File lib/puppet/parser/ast/resource.rb, line 15
15:   def evaluate(scope)
16:     # Evaluate all of the specified params.
17:     paramobjects = parameters.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:     resource_titles = [resource_titles] unless resource_titles.is_a?(Array)
25: 
26:     # We want virtual to be true if exported is true.  We can't
27:     # just set :virtual => self.virtual in the initialization,
28:     # because sometimes the :virtual attribute is set *after*
29:     # :exported, in which case it clobbers :exported if :exported
30:     # is true.  Argh, this was a very tough one to track down.
31:     virt = self.virtual || self.exported
32: 
33:     # This is where our implicit iteration takes place; if someone
34:     # passed an array as the name, then we act just like the called us
35:     # many times.
36:     fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles)
37: 
38:     resource_titles.flatten.collect { |resource_title|
39:       exceptwrap :type => Puppet::ParseError do
40:         resource = Puppet::Parser::Resource.new(
41:           fully_qualified_type, resource_title,
42:           :parameters => paramobjects,
43:           :file => self.file,
44:           :line => self.line,
45:           :exported => self.exported,
46:           :virtual => virt,
47:           :source => scope.source,
48:           :scope => scope,
49:           :strict => true
50:         )
51: 
52:         if resource.resource_type.is_a? Puppet::Resource::Type
53:           resource.resource_type.instantiate_resource(scope, resource)
54:         end
55:         scope.compiler.add_resource(scope, resource)
56:         scope.compiler.evaluate_classes([resource_title],scope,false) if fully_qualified_type == 'class'
57:         resource
58:       end
59:     }.reject { |resource| resource.nil? }
60:   end