module ViewModel::AfterTransactionRunner

def add_to_transaction

def add_to_transaction
  if connection.transaction_open?
    connection.add_transaction_record(self)
  else
    before_commit
    after_commit
  end
end

def after_commit; end

def after_commit; end

def after_rollback; end

def after_rollback; end

def before_commit; end

def before_commit; end

def before_committed!

def before_committed!
  before_commit
end

def committed!(*)

Rails' internal API
def committed!(*)
  after_commit
end

def connection

Override to tie to a specific connection.
def connection
  ActiveRecord::Base.connection
end

def rolledback!(*)

def rolledback!(*)
  after_rollback
end

def trigger_transactional_callbacks?

def trigger_transactional_callbacks?
  true
end