Module: Cms::Behaviors::SoftDeleting::InstanceMethods

Defined in:
lib/cms/behaviors/soft_deleting.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

Destroying a soft deletable model should mark the record as deleted, and not actually remove it from the database.

Overrides original destroy method


82
83
84
85
86
87
88
89
90
# File 'lib/cms/behaviors/soft_deleting.rb', line 82

def destroy
  run_callbacks :destroy do
    if self.class.publishable?
      update_attributes(:deleted => true, :publish_on_save => true)
    else
      update_attributes(:deleted => true)
    end
  end
end

#destroy!Object


96
97
98
# File 'lib/cms/behaviors/soft_deleting.rb', line 96

def destroy!
  transaction { super.destroy }
end

#destroyed?Boolean


100
101
102
# File 'lib/cms/behaviors/soft_deleting.rb', line 100

def destroyed?
  @destroyed
end

#mark_as_deleted!Object


92
93
94
# File 'lib/cms/behaviors/soft_deleting.rb', line 92

def mark_as_deleted!
  destroy
end