Sha256: ffe17017a9f718abd72bf5894fa8d38208483b6b86a09982a3b0c567fbe96843

Contents?: true

Size: 717 Bytes

Versions: 11

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true
require 'fresh_connection/extend/adapters/base_adapter'

module FreshConnection
  module Extend
    module PgAdapter
      private

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

        master_connection = @connection
        master_statements = @statements
        begin
          replica_connection = @model_class.replica_connection
          @connection = replica_connection.raw_connection
          @statements = replica_connection.instance_variable_get(:@statements)
          yield
        ensure
          @connection = master_connection
          @statements = master_statements
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fresh_connection-3.1.3 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.1.2 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.1.1 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.1.1.rc1 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.1.0 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.0.3 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.0.2 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.0.2.rc1 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.0.1 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.0.1.rc2 lib/fresh_connection/extend/adapters/pg_adapter.rb
fresh_connection-3.0.1.rc1 lib/fresh_connection/extend/adapters/pg_adapter.rb