module ViewModel::AfterTransactionRunner

Module implementing the behaviour of a AR post-transaction hook. After calling `add_to_transaction`, the abstract method `after_transaction` will be invoked by AR's callbacks.

Public Instance Methods

add_to_transaction() click to toggle source
# File lib/view_model/after_transaction_runner.rb, line 32
def add_to_transaction
  if connection.transaction_open?
    connection.add_transaction_record(self)
  else
    before_commit
    after_commit
  end
end
after_commit() click to toggle source
# File lib/view_model/after_transaction_runner.rb, line 28
def after_commit; end
after_rollback() click to toggle source
# File lib/view_model/after_transaction_runner.rb, line 30
def after_rollback; end
before_commit() click to toggle source

Our simplified API

# File lib/view_model/after_transaction_runner.rb, line 26
def before_commit; end
before_committed!() click to toggle source
# File lib/view_model/after_transaction_runner.rb, line 12
def before_committed!
  before_commit
end
committed!(*) click to toggle source

Rails' internal API

# File lib/view_model/after_transaction_runner.rb, line 8
def committed!(*)
  after_commit
end
connection() click to toggle source

Override to tie to a specific connection.

# File lib/view_model/after_transaction_runner.rb, line 42
def connection
  ActiveRecord::Base.connection
end
rolledback!(*) click to toggle source
# File lib/view_model/after_transaction_runner.rb, line 16
def rolledback!(*)
  after_rollback
end
trigger_transactional_callbacks?() click to toggle source
# File lib/view_model/after_transaction_runner.rb, line 20
def trigger_transactional_callbacks?
  true
end