class AfterCommitEverywhere::Wrap

ActiveRecord model-like class to fake ActiveRecord to make it believe that it calls transactional callbacks on real model objects.

Public Class Methods

new(connection: ActiveRecord::Base.connection, **handlers) click to toggle source
# File lib/after_commit_everywhere/wrap.rb, line 7
def initialize(connection: ActiveRecord::Base.connection, **handlers)
  @connection = connection
  @handlers = handlers
end

Public Instance Methods

add_to_transaction(*) click to toggle source

Required for +transaction(requires_new: true)+

# File lib/after_commit_everywhere/wrap.rb, line 35
def add_to_transaction(*)
  @connection.add_transaction_record(self)
end
before_committed!(*) click to toggle source

rubocop: enable Naming/PredicateName

# File lib/after_commit_everywhere/wrap.rb, line 18
def before_committed!(*)
  @handlers[:before_commit]&.call
end
committed!(*) click to toggle source
# File lib/after_commit_everywhere/wrap.rb, line 26
def committed!(*)
  @handlers[:after_commit]&.call
end
has_transactional_callbacks?() click to toggle source

rubocop: disable Naming/PredicateName

# File lib/after_commit_everywhere/wrap.rb, line 13
def has_transactional_callbacks?
  true
end
rolledback!(*) click to toggle source
# File lib/after_commit_everywhere/wrap.rb, line 30
def rolledback!(*)
  @handlers[:after_rollback]&.call
end
trigger_transactional_callbacks?() click to toggle source
# File lib/after_commit_everywhere/wrap.rb, line 22
def trigger_transactional_callbacks?
  true
end