# File lib/puppet/resource.rb, line 302
302:   def to_transobject
303:     # Now convert to a transobject
304:     result = Puppet::TransObject.new(title, type)
305:     to_hash.each do |p, v|
306:       if v.is_a?(Puppet::Resource)
307:         v = v.to_trans_ref
308:       elsif v.is_a?(Array)
309:         v = v.collect { |av|
310:           av = av.to_trans_ref if av.is_a?(Puppet::Resource)
311:           av
312:         }
313:       end
314: 
315:       # If the value is an array with only one value, then
316:       # convert it to a single value.  This is largely so that
317:       # the database interaction doesn't have to worry about
318:       # whether it returns an array or a string.
319:       result[p.to_s] = if v.is_a?(Array) and v.length == 1
320:         v[0]
321:           else
322:             v
323:               end
324:     end
325: 
326:     result.tags = self.tags
327: 
328:     result
329:   end