Sha256: 4b2eddf627b731d03bf4c2cc234cbe0d4b157a507508613ac499efe4e5c0b074
Contents?: true
Size: 921 Bytes
Versions: 10
Compression:
Stored size: 921 Bytes
Contents
# frozen_string_literal: true module AfterCommitEverywhere # ActiveRecord model-like class to fake ActiveRecord to make it believe # that it calls transactional callbacks on real model objects. class Wrap def initialize(connection: ActiveRecord::Base.connection, **handlers) @connection = connection @handlers = handlers end # rubocop: disable Naming/PredicateName def has_transactional_callbacks? true end # rubocop: enable Naming/PredicateName def before_committed!(*) @handlers[:before_commit]&.call end def trigger_transactional_callbacks? true end def committed!(*) @handlers[:after_commit]&.call end def rolledback!(*) @handlers[:after_rollback]&.call end # Required for +transaction(requires_new: true)+ def add_to_transaction(*) @connection.add_transaction_record(self) end end end
Version data entries
10 entries across 10 versions & 1 rubygems