Module: SoftDeletion::Setup::ClassMethods
- Defined in:
- lib/soft_deletion/setup.rb
Instance Method Summary collapse
-
#has_soft_deletion(options = {}) ⇒ Object
When you call this, it will include the core module and its methods.
Instance Method Details
#has_soft_deletion(options = {}) ⇒ Object
When you call this, it will include the core module and its methods
Options:
default_scope, value: true/false If true, it will also define a default scope
It will check if the column “deleted_at” exist before applying default scope
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/soft_deletion/setup.rb', line 17 def has_soft_deletion(={}) include SoftDeletion::Core if [:default_scope] self.soft_delete_default_scope = name default_scope do if Thread.current[:"soft_deletion_with_deleted_#{soft_delete_default_scope}"] where(nil) else where(deleted_at: nil) end end end end |