class ActiveRecord::Relation

Public Instance Methods

delete_all(*args, &block) click to toggle source
# File lib/mark_only.rb, line 78
def delete_all(*args, &block)
  return mark_only_orig_relation_delete_all(*args, &block) unless !!::MarkOnly.enabled
  if klass.respond_to?(:mark_only?) && klass.mark_only?
    logger.debug("will not #{self}.delete_all", e) if MarkOnly.debug
    if args.length > 0 && block_given?
      where(*args, &block)
    elsif args.length > 0 && !block_given?
      where(*args)
    elsif args.length == 0 && block_given?
      where(&block)
    end
    c = "#{quoted_table_name}.#{connection.quote_column_name self.mark_only_column}"
    where("#{c} != ? OR #{c} IS NULL", MarkOnly.deleted_value)
    update_all({self.mark_only_column => MarkOnly.deleted_value})
  else
    mark_only_orig_relation_delete_all(*args, &block)
  end
end
destroy_all(*args, &block) click to toggle source
# File lib/mark_only.rb, line 99
def destroy_all(*args, &block)
  return mark_only_orig_relation_destroy_all(*args, &block) unless !!::MarkOnly.enabled
  if klass.respond_to?(:mark_only?) && klass.mark_only?
    logger.debug("will not #{self}.destroy_all", e) if MarkOnly.debug
    if args.length > 0 && block_given?
      where(*args, &block)
    elsif args.length > 0 && !block_given?
      where(*args)
    elsif args.length == 0 && block_given?
      where(&block)
    end
    c = "#{quoted_table_name}.#{connection.quote_column_name self.mark_only_column}"
    where("#{c} != ? OR #{c} IS NULL", MarkOnly.deleted_value)
    update_all({self.mark_only_column => MarkOnly.deleted_value})
    #rel.to_a.each {|object| object.run_callbacks(:destroy) { delete }}.tap { reset }
  else
    mark_only_orig_relation_destroy_all(*args, &block)
  end
end
mark_only_orig_relation_delete_all(*args, &block)

don’t use generic naming to try to avoid conflicts, since this isn’t model class specific

Alias for: delete_all
mark_only_orig_relation_destroy_all(*args, &block)

don’t use generic naming to try to avoid conflicts, since this isn’t model class specific

Alias for: destroy_all