module MarkOnly::ClassMethods

Public Instance Methods

delete(id_or_array) click to toggle source
Calls superclass method
# File lib/mark_only.rb, line 18
def delete(id_or_array)
  return super(id_or_array) unless !!::MarkOnly.enabled
  logger.debug("will not #{self}.delete #{id_or_array.inspect}", e) if MarkOnly.debug
  c = "#{quoted_table_name}.#{connection.quote_column_name self.mark_only_column}"
  self.
    where(primary_key => id_or_array).
    where("#{c} != ? OR #{c} IS NULL", MarkOnly.deleted_value).
    update_all({self.mark_only_column => MarkOnly.deleted_value})
end
delete_all(conditions = nil) click to toggle source
Calls superclass method
# File lib/mark_only.rb, line 28
def delete_all(conditions = nil)
  return super(conditions) unless !!::MarkOnly.enabled
  logger.debug("will not #{self}.delete_all", e) if MarkOnly.debug
  c = "#{quoted_table_name}.#{connection.quote_column_name self.mark_only_column}"
  (conditions ? self.where(conditions) : self).
    where("#{c} != ? OR #{c} IS NULL", MarkOnly.deleted_value).
    update_all({self.mark_only_column => MarkOnly.deleted_value})
end
mark_only?() click to toggle source
# File lib/mark_only.rb, line 14
def mark_only?
  true
end