Sha256: 0b83f451607b5544a1d36430a3a6bddd33f0a9c8bf24de4cca64143ae600fbbe

Contents?: true

Size: 710 Bytes

Versions: 6

Compression:

Stored size: 710 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    class AbstractAdapter
      def select_all_with_slave_connection(arel, name = nil, binds = [])
        if FreshConnection::SlaveConnection.slave_access?
          change_connection {select_all_without_slave_connection(arel, "[slave] #{name}", binds)}
        else
          select_all_without_slave_connection(arel, name, binds)
        end
      end
      alias_method_chain :select_all, :slave_connection

      private

      def change_connection
        master_connection, @connection =
          @connection, FreshConnection::SlaveConnection.raw_connection
        yield
      ensure
        @connection = master_connection
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fresh_connection-0.1.6 lib/fresh_connection/active_record/abstract_adapter.rb
fresh_connection-0.1.5 lib/fresh_connection/active_record/abstract_adapter.rb
fresh_connection-0.1.4 lib/fresh_connection/active_record/abstract_adapter.rb
fresh_connection-0.1.3 lib/fresh_connection/active_record/abstract_adapter.rb
fresh_connection-0.1.2 lib/fresh_connection/active_record/abstract_adapter.rb
fresh_connection-0.1.1 lib/fresh_connection/active_record/abstract_adapter.rb