Module: NoBrainerSoftDelete
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/no_brainer_soft_delete.rb,
lib/no_brainer_soft_delete/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
-
#deleted? ⇒ Boolean
Returns a boolean indicating whether or not a document has been soft deleted.
-
#destroy ⇒ Object
Sets the deleted_at value to the current time, thus marking the document as deleted.
-
#really_destroy! ⇒ Object
Completely removes the document from the database, and runs the callbacks.
-
#restore(options = {}) ⇒ Object
Sets the deleted_at value to nil, thus no longer marking the document as deleted TODO: add a recursive option restore that restores soft deleted associations as well.
Instance Method Details
#deleted? ⇒ Boolean
Returns a boolean indicating whether or not a document has been soft deleted
34 35 36 |
# File 'lib/no_brainer_soft_delete.rb', line 34 def deleted? !!deleted_at end |
#destroy ⇒ Object
Sets the deleted_at value to the current time, thus marking the document as deleted
39 40 41 |
# File 'lib/no_brainer_soft_delete.rb', line 39 def destroy update(deleted_at: Time.now.utc) end |
#really_destroy! ⇒ Object
Completely removes the document from the database, and runs the callbacks.
44 45 46 47 |
# File 'lib/no_brainer_soft_delete.rb', line 44 def really_destroy! _run_destroy_callbacks delete end |
#restore(options = {}) ⇒ Object
Sets the deleted_at value to nil, thus no longer marking the document as deleted TODO: add a recursive option restore that restores soft deleted associations as well.
51 52 53 |
# File 'lib/no_brainer_soft_delete.rb', line 51 def restore( = {}) update(deleted_at: nil) end |