class ActionCommand::ExecutableTransaction
Root class for action commands that can be executed by this library. Override execute_internal to implement one, call one of the variants of ActionCommand.execute_… to execute one.
Public Instance Methods
execute(result)
click to toggle source
starts a transaction only if we are not already within one.
Calls superclass method
ActionCommand::Executable#execute
# File lib/action_command/executable_transaction.rb, line 8 def execute(result) if ActiveRecord::Base.connection.open_transactions >= 1 super(result) else result.info('start_transaction') ActiveRecord::Base.transaction do super(result) if result.ok? result.info('end_transaction') else result.info('rollback_transaction') raise ActiveRecord::Rollback, 'rollback transaction' end end end end