Sha256: 1e18f2376bb86711607274e168fcb0ec022bbd0e27df269ca294f3fb5a18594a

Contents?: true

Size: 498 Bytes

Versions: 2

Compression:

Stored size: 498 Bytes

Contents

# frozen_string_literal: true

module FreshConnection
  module Extend
    module M2Adapter
      private

      def change_connection
        return yield unless FreshConnection::AccessControl.replica_access?

        master_connection = @connection
        begin
          replica_connection = @model_class.replica_connection
          @connection = replica_connection.raw_connection
          yield
        ensure
          @connection = master_connection
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fresh_connection-3.0.0 lib/fresh_connection/extend/adapters/m2_adapter.rb
fresh_connection-3.0.0.rc2 lib/fresh_connection/extend/adapters/m2_adapter.rb