# File lib/puppet/parser/resource.rb, line 181
181:   def to_resource
182:     result = Puppet::Resource.new(type, title)
183: 
184:     to_hash.each do |p, v|
185:       if v.is_a?(Puppet::Resource)
186:         v = Puppet::Resource.new(v.type, v.title)
187:       elsif v.is_a?(Array)
188:         # flatten resource references arrays
189:         v = v.flatten if v.flatten.find { |av| av.is_a?(Puppet::Resource) }
190:         v = v.collect do |av|
191:           av = Puppet::Resource.new(av.type, av.title) if av.is_a?(Puppet::Resource)
192:           av
193:         end
194:       end
195: 
196:       # If the value is an array with only one value, then
197:       # convert it to a single value.  This is largely so that
198:       # the database interaction doesn't have to worry about
199:       # whether it returns an array or a string.
200:       result[p] = if v.is_a?(Array) and v.length == 1
201:         v[0]
202:           else
203:             v
204:               end
205:     end
206: 
207:     result.file = self.file
208:     result.line = self.line
209:     result.exported = self.exported
210:     result.virtual = self.virtual
211:     result.tag(*self.tags)
212: 
213:     result
214:   end