Module: MongoMapper::Plugins::Paranoia::InstanceMethods
- Defined in:
- lib/mongo_mapper/paranoia.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
(also: #delete)
Destroys the instance.
-
#destroyed? ⇒ true, false
(also: #deleted?)
Whether or not the deleted_at attribute is set.
-
#ensure_active ⇒ Object
(also: #undestroy, #undelete)
Sets the deleted_at attribute to nil, if present.
Instance Method Details
#destroy ⇒ Object Also known as: delete
Destroys the instance
22 23 24 25 26 |
# File 'lib/mongo_mapper/paranoia.rb', line 22 def destroy run_callbacks(:destroy) do update_attribute(:deleted_at, Time.now) end end |
#destroyed? ⇒ true, false Also known as: deleted?
Returns Whether or not the deleted_at attribute is set.
30 31 32 |
# File 'lib/mongo_mapper/paranoia.rb', line 30 def destroyed? self.deleted_at.present? end |
#ensure_active ⇒ Object Also known as: undestroy, undelete
Sets the deleted_at attribute to nil, if present
37 38 39 40 41 |
# File 'lib/mongo_mapper/paranoia.rb', line 37 def ensure_active run_callbacks(:destroy) do update_attribute(:deleted_at, nil) end end |