Module: ROM::SQL::Commands::Transaction Private

Included in:
Create, Delete, Update
Defined in:
lib/rom/sql/commands/transaction.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adds transaction interface to commands

Instance Method Summary collapse

Instance Method Details

#transaction(options = {}, &block) ⇒ ROM::Commands::Result::Success, ROM::Commands::Result::Failure

Start a transaction



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rom/sql/commands/transaction.rb', line 19

def transaction(options = {}, &block)
  result = relation.dataset.db.transaction(options, &block)

  if result
    ROM::Commands::Result::Success.new(result)
  else
    ROM::Commands::Result::Failure.new(result)
  end
rescue ROM::CommandError => e
  ROM::Commands::Result::Failure.new(e)
end