Class: PikoTransaction::DeleteCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/piko_transaction/delete_command.rb

Instance Method Summary collapse

Methods inherited from Command

#add_failure_callback, #add_success_callback, #name, #to_s

Methods included from Logger

#logger

Constructor Details

#initialize(document_id, collection, &success_action) ⇒ DeleteCommand

Returns a new instance of DeleteCommand.



24
25
26
27
28
29
30
# File 'lib/piko_transaction/delete_command.rb', line 24

def initialize(document_id, collection, &success_action)
  super()
  @document_id = document_id
  @collection = collection
  @success_action = success_action
  @deleted_doc = nil
end

Instance Method Details

#doObject



32
33
34
35
# File 'lib/piko_transaction/delete_command.rb', line 32

def do
  add_success_callback @success_action
  remove_document ? call_success_callbacks : call_failure_callbacks
end

#undoObject



37
38
39
# File 'lib/piko_transaction/delete_command.rb', line 37

def undo
  store_document
end