Class: PikoTransaction::CustomCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/piko_transaction/custom_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(do_action = nil, undo_action = nil, &alternative_do_action) ⇒ CustomCommand

Returns a new instance of CustomCommand.



24
25
26
27
28
# File 'lib/piko_transaction/custom_command.rb', line 24

def initialize(do_action = nil, undo_action = nil, &alternative_do_action)
  super()
  @do_action = choose_do_action(do_action, alternative_do_action)
  @undo_action = undo_action
end

Instance Method Details

#doObject



30
31
32
# File 'lib/piko_transaction/custom_command.rb', line 30

def do
  execute_do_action ? call_success_callbacks : call_failure_callbacks
end

#undoObject



34
35
36
# File 'lib/piko_transaction/custom_command.rb', line 34

def undo
  execute_undo_action
end