# File lib/puppet/rails/host.rb, line 196
196:   def remove_unneeded_resources(compiled, existing)
197:     deletions = []
198:     resources = {}
199:     existing.each do |id, resource|
200:       # it seems that it can happen (see bug #2010) some resources are duplicated in the
201:       # database (ie logically corrupted database), in which case we remove the extraneous
202:       # entries.
203:       if resources.include?(resource.ref)
204:         deletions << id
205:         next
206:       end
207: 
208:       # If the resource is in the db but not in the catalog, mark it
209:       # for removal.
210:       unless compiled.include?(resource.ref)
211:         deletions << id
212:         next
213:       end
214: 
215:       resources[resource.ref] = resource
216:     end
217:     # We need to use 'destroy' here, not 'delete', so that all
218:     # dependent objects get removed, too.
219:     Puppet::Rails::Resource.destroy(deletions) unless deletions.empty?
220: 
221:     resources
222:   end