Class: Memento::Action::Destroy

Inherits:
Base
  • Object
show all
Defined in:
lib/memento/action/destroy.rb

Instance Attribute Summary

Attributes inherited from Base

#state

Instance Method Summary collapse

Methods inherited from Base

#fetch?, inherited, #initialize, #record, #record_data

Constructor Details

This class inherits a constructor from Memento::Action::Base

Instance Method Details

#fetchObject



4
5
6
# File 'lib/memento/action/destroy.rb', line 4

def fetch
  record.attributes_for_memento
end

#undoObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/memento/action/destroy.rb', line 8

def undo
  rebuild_object do |object|
    begin
      object.save!
    rescue
      object.id = nil
      object.save!
    end
    state.record = object
    state.save
  end
end