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



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

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



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

def destroy!
  transaction { super.destroy }
end

#destroyed?Boolean

Returns:

  • (Boolean)


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

def destroyed?
  @destroyed
end

#mark_as_deleted!Object



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

def mark_as_deleted!
  destroy
end