Module: Cms::Behaviors::SoftDeleting::InstanceMethods
- Defined in:
- lib/cms/behaviors/soft_deleting.rb
Instance Method Summary collapse
- #destroy! ⇒ Object
- #destroy_with_callbacks! ⇒ Object
-
#destroy_without_callbacks ⇒ Object
Overrides original destroy method.
- #destroyed? ⇒ Boolean
- #mark_as_deleted! ⇒ Object
Instance Method Details
#destroy! ⇒ Object
67 68 69 |
# File 'lib/cms/behaviors/soft_deleting.rb', line 67 def destroy! transaction { destroy_with_callbacks! } end |
#destroy_with_callbacks! ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/cms/behaviors/soft_deleting.rb', line 59 def destroy_with_callbacks! return false if callback(:before_destroy) == false result = destroy_without_callbacks! @destroyed = true callback(:after_destroy) result end |
#destroy_without_callbacks ⇒ Object
Overrides original destroy method
47 48 49 50 51 52 53 |
# File 'lib/cms/behaviors/soft_deleting.rb', line 47 def destroy_without_callbacks if self.class.publishable? update_attributes(:deleted => true, :publish_on_save => true) else update_attributes(:deleted => true) end end |
#destroyed? ⇒ Boolean
71 72 73 |
# File 'lib/cms/behaviors/soft_deleting.rb', line 71 def destroyed? @destroyed end |
#mark_as_deleted! ⇒ Object
55 56 57 |
# File 'lib/cms/behaviors/soft_deleting.rb', line 55 def mark_as_deleted! destroy_without_callbacks end |