Module: Calib::Devise::SoftDeletion

Extended by:
ActiveSupport::Concern
Defined in:
lib/calib/devise/soft_deletion.rb

Overview

Soft deletation for devise

use with SoftDeletionMigrationEnhancable

usage

include to Devise Model.

class User < ApplicationRecord
  include Calib::Devise::SoftDeletion

  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :confirmable  

  devise_soft_deletable # call below `device` method 

  ...
end

Instance Method Summary collapse

Instance Method Details

#alive_valueObject

get alive_column_value


67
68
69
# File 'lib/calib/devise/soft_deletion.rb', line 67

def alive_value
  self.send(self.class.alive_column_name)
end

#canceled?Boolean

check canceled

Returns:

  • (Boolean)

52
53
54
# File 'lib/calib/devise/soft_deletion.rb', line 52

def canceled?
  self.alive_value == nil
end

#soft_destroyObject

do soft destroy


57
58
59
# File 'lib/calib/devise/soft_deletion.rb', line 57

def soft_destroy
  save if pre_destroy
end

#soft_destroy!Object

do soft destroy!


62
63
64
# File 'lib/calib/devise/soft_deletion.rb', line 62

def soft_destroy!
  save! if pre_destroy
end