# File lib/dm-core/associations/many_to_many.rb, line 348 def destroy! assert_source_saved 'The source must be saved before mass-deleting the collection' model = self.model key = model.key(repository_name) conditions = Query.target_conditions(self, key, key) unless intermediaries.all(via => self).destroy! return false end unless model.all(:repository => repository, :conditions => conditions).destroy! return false end each do |resource| resource.persisted_state = Resource::State::Immutable.new(resource) end clear true end