No commit activity in last 3 years
No release in over 3 years
Soft Deletable for ActiveRecord.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
>= 0
~> 10.0
~> 3.0

Runtime

 Project Readme

SoftDeletablePetit

Based on kakurenbo-puti.

Installation

Add this line to your application's Gemfile:

gem 'soft_deletable_petit'

And then execute:

$ bundle

Or install it yourself as:

$ gem install soft_deletable_petit

Usage

Add deleted_at column to your model.

and

class YourModel < ActiveRecord::Base
  soft_deletable
end

Methods

m.destroy_softly # or destroy_softly!
m.deleted? # => true

m.restore # or m.restore!
m.living? # => true

Scopes

YourModel.living
YourModel.deleted

Configuration

In model

class YourModel < ActiveRecord::Base
  soft_deletable \
    column:                     :deleted_at,
    soft_delete_method_name:    :destroy_softly,
    restore_method_name:        :restore,
    soft_deleted_scope:         :deleted,
    without_soft_deleted_scope: :living
end

and you can change default configuration with SoftDeletablePetit.configure.

# config/initializers/soft_deletable_petit.rb
SoftDeletablePetit.configure do |config|
  config.column                     = :deleted_at
  config.soft_delete_method_name    = :destroy_softly
  config.restore_method_name        = :restore
  config.soft_deleted_scope         = :deleted
  config.without_soft_deleted_scope = :living
end