Module: Archive2s::InstanceMethods
- Defined in:
- lib/archive_2s.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#destroy_with_archive ⇒ Object
wrap it all up in a transaction.
Class Method Details
.included(base) ⇒ Object
38 39 40 41 42 |
# File 'lib/archive_2s.rb', line 38 def self.included(base) base.class_eval do alias_method_chain :destroy, :archive end end |
Instance Method Details
#destroy_with_archive ⇒ Object
wrap it all up in a transaction
45 46 47 48 49 50 51 |
# File 'lib/archive_2s.rb', line 45 def destroy_with_archive self.class.transaction do archived = ::Archive2s::Model.new(:model => self, :archived_value => self.send(self.class.archive_2s_args[:method_name]), :archived_at => Time.now) archived.save! destroy_without_archive end end |