# File lib/puppet/rails/host.rb, line 264
264:     def remove_unneeded_resources(compiled, existing)
265:         deletions = []
266:         resources = {}
267:         existing.each do |id, resource|
268:             # it seems that it can happen (see bug #2010) some resources are duplicated in the
269:             # database (ie logically corrupted database), in which case we remove the extraneous
270:             # entries.
271:             if resources.include?(resource.ref)
272:                 deletions << id
273:                 next
274:             end
275: 
276:             # If the resource is in the db but not in the catalog, mark it
277:             # for removal.
278:             unless compiled.include?(resource.ref)
279:                 deletions << id
280:                 next
281:             end
282: 
283:             resources[resource.ref] = resource
284:         end
285:         # We need to use 'destroy' here, not 'delete', so that all
286:         # dependent objects get removed, too.
287:         Puppet::Rails::Resource.destroy(deletions) unless deletions.empty?
288: 
289:         return resources
290:     end