Module: Mongoid::Undo
- Extended by:
- ActiveSupport::Concern
- Includes:
- Interceptable, Paranoia, Versioning
- Defined in:
- lib/mongoid/undo.rb,
lib/mongoid/undo/version.rb
Constant Summary collapse
- VERSION =
'1.1.0'
Instance Method Summary collapse
- #undo ⇒ Object (also: #redo)
- #undoable? ⇒ Boolean (also: #redoable?)
Instance Method Details
#undo ⇒ Object Also known as: redo
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mongoid/undo.rb', line 43 def undo run_callbacks __callee__ do case action when :create, :destroy deleted_at.present? ? restore : delete when :update retrieve end end end |
#undoable? ⇒ Boolean Also known as: redoable?
55 56 57 58 59 60 61 62 |
# File 'lib/mongoid/undo.rb', line 55 def undoable? case action when :create, :destroy true when :update read_attribute(:version).to_i > @version end end |