Sha256: 30ea69f344c5d3a886cec23cf20477e1b2b8d0de7e3687bfb7bfe2a214a7166f

Contents?: true

Size: 649 Bytes

Versions: 1

Compression:

Stored size: 649 Bytes

Contents

# frozen_string_literal: true

module FreshConnection
  module Extend
    module M2Adapter
      def select_all(*args)
        change_connection { super }
      end

      def select_rows(*args)
        change_connection { super }
      end

      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

1 entries across 1 versions & 1 rubygems

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