module ActiveRecord::Persistence::ClassMethods
Public Instance Methods
delete(id_or_array)
click to toggle source
# File lib/composite_primary_keys/persistence.rb, line 4 def delete(id_or_array) # CPK if self.composite? id_or_array = if id_or_array.is_a?(CompositePrimaryKeys::CompositeKeys) [id_or_array] else Array(id_or_array) end # Delete should return the number of deleted records id_or_array.map do |id| # Is the passed in id actually a record? id = id.kind_of?(::ActiveRecord::Base) ? id.id : id delete_by(cpk_id_predicate(self.arel_table, self.primary_key, id)) end.sum else delete_by(primary_key => id_or_array) end end