Sha256: 2bb8b009b1e13dbad57a3f163c8dafd57134251ad7e3d33ee50bbd2c589a2870
Contents?: true
Size: 1.4 KB
Versions: 30
Compression:
Stored size: 1.4 KB
Contents
module CompositePrimaryKeys module CompositeRelation include CompositePrimaryKeys::ActiveRecord::Batches include CompositePrimaryKeys::ActiveRecord::Calculations include CompositePrimaryKeys::ActiveRecord::FinderMethods include CompositePrimaryKeys::ActiveRecord::QueryMethods 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 id_or_array.each do |id| # Is the passed in id actually a record? id = id.kind_of?(::ActiveRecord::Base) ? id.id : id where(cpk_id_predicate(table, self.primary_key, id)).delete_all end else where(primary_key => id_or_array).delete_all end end def destroy(id_or_array) # Without CPK: #if id.is_a?(Array) # id.map { |one_id| destroy(one_id) } #else # find(id).destroy #end id_or_array = if id_or_array.kind_of?(CompositePrimaryKeys::CompositeKeys) [id_or_array] else Array(id_or_array) end id_or_array.each do |id| where(cpk_id_predicate(table, self.primary_key, id)).each do |record| record.destroy end end end end end
Version data entries
30 entries across 30 versions & 1 rubygems