# File lib/puppet/parser/resource.rb, line 249
249:     def to_resource
250:         result = Puppet::Resource.new(type, title)
251: 
252:         to_hash.each do |p, v|
253:             if v.is_a?(Puppet::Parser::Resource::Reference)
254:                 v = Puppet::Resource::Reference.new(v.type, v.title)
255:             elsif v.is_a?(Array)
256:                 # flatten resource references arrays
257:                 if v.flatten.find { |av| av.is_a?(Puppet::Parser::Resource::Reference) }
258:                     v = v.flatten
259:                 end
260:                 v = v.collect do |av|
261:                     if av.is_a?(Puppet::Parser::Resource::Reference)
262:                         av = Puppet::Resource::Reference.new(av.type, av.title)
263:                     end
264:                     av
265:                 end
266:             end
267: 
268:             # If the value is an array with only one value, then
269:             # convert it to a single value.  This is largely so that
270:             # the database interaction doesn't have to worry about
271:             # whether it returns an array or a string.
272:             result[p] = if v.is_a?(Array) and v.length == 1
273:                               v[0]
274:                           else
275:                               v
276:                           end
277:         end
278: 
279:         result.file = self.file
280:         result.line = self.line
281:         result.exported = self.exported
282:         result.virtual = self.virtual
283:         result.tag(*self.tags)
284: 
285:         return result
286:     end