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

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

Instance Method Summary collapse

Instance Method Details

#destroy!Object



63
64
65
# File 'lib/cms/behaviors/soft_deleting.rb', line 63

def destroy!
  transaction { destroy_with_callbacks! }
end

#destroy_with_callbacks!Object



55
56
57
58
59
60
61
# File 'lib/cms/behaviors/soft_deleting.rb', line 55

def destroy_with_callbacks!
  return false if callback(:before_destroy) == false
  result = destroy_without_callbacks!
  @destroyed = true
  callback(:after_destroy)
  result
end

#destroy_without_callbacksObject

Overrides original destroy method



47
48
49
# File 'lib/cms/behaviors/soft_deleting.rb', line 47

def destroy_without_callbacks
  update_attribute(:deleted, true)
end

#destroyed?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/cms/behaviors/soft_deleting.rb', line 67

def destroyed?
  @destroyed
end

#mark_as_deleted!Object



51
52
53
# File 'lib/cms/behaviors/soft_deleting.rb', line 51

def mark_as_deleted!
  destroy_without_callbacks
end