Class: Memento::Action::Update

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

Instance Attribute Summary

Attributes inherited from Base

#state

Instance Method Summary collapse

Methods inherited from Base

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/update.rb', line 4

def fetch
  record.changes_for_memento
end

#fetch?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/memento/action/update.rb', line 8

def fetch?
  record.changes_for_memento.any?
end

#undoObject



12
13
14
15
16
17
18
19
20
# File 'lib/memento/action/update.rb', line 12

def undo
  if !record
    was_destroyed
  elsif mergable?
    update_record
  else
    was_changed
  end
end