Module: ActsAsArchive::Base::Destroy::InstanceMethods

Defined in:
lib/acts_as_archive/base/destroy.rb

Instance Method Summary collapse

Instance Method Details

#destroy!Object



58
59
60
# File 'lib/acts_as_archive/base/destroy.rb', line 58

def destroy!
  transaction { destroy_with_callbacks! }
end

#destroy_with_callbacks!Object



62
63
64
65
66
67
# File 'lib/acts_as_archive/base/destroy.rb', line 62

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

#destroy_without_callbacksObject



50
51
52
53
54
55
56
# File 'lib/acts_as_archive/base/destroy.rb', line 50

def destroy_without_callbacks
  unless new_record?
    self.class.copy_to_archive("#{self.class.primary_key} = #{id}")
  end
  @destroyed = true
  freeze
end