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



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

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



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

def destroy!
  transaction { super.destroy }
end

#destroyed?Boolean

Returns:

  • (Boolean)


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

def destroyed?
  @destroyed
end

#mark_as_deleted!Object



89
90
91
# File 'lib/cms/behaviors/soft_deleting.rb', line 89

def mark_as_deleted!
  destroy
end