Sha256: 195d603b96f16c74ca4c97c2331375bf9470b88f3eef636e3aaea67ce1cdcece

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

module FreshConnection
  module Extend
    module ArAbstractAdapter
      def self.prepended(base)
        base.send :attr_accessor, :replica_spec_name, :master_connection
      end

      def log(*args)
        args[1] = "[#{@replica_spec_name}] #{args[1]}" if defined?(@replica_spec_name)
        super
      end

      def query_cache
        return @query_cache unless master_connection
        master_connection.query_cache
      end

      def query_cache_enabled
        return @query_cache_enabled unless master_connection
        master_connection.query_cache_enabled
      end

      def cache(&block)
        return super unless master_connection
        master_connection.cache(&block)
      end

      def enable_query_cache!
        return super unless master_connection
        master_connection.enable_query_cache!
      end

      def disable_query_cache!
        return super unless master_connection
        master_connection.disable_query_cache!
      end

      def uncached(&block)
        return super unless master_connection
        master_connection.uncached(&block)
      end

      def clear_query_cache
        return super unless master_connection
        master_conection.clear_query_cache
      end

      def select_all(*args)
        return super unless master_connection
        @query_cache_enabled = master_connection.query_cache_enabled
        super
      end

      private

      def cache_sql(*args)
        return super unless master_connection
        @query_cache = master_connection.query_cache
        super
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fresh_connection-2.4.4 lib/fresh_connection/extend/ar_abstract_adapter.rb
fresh_connection-2.4.3 lib/fresh_connection/extend/ar_abstract_adapter.rb
fresh_connection-2.4.2 lib/fresh_connection/extend/ar_abstract_adapter.rb
fresh_connection-2.4.1 lib/fresh_connection/extend/ar_abstract_adapter.rb
fresh_connection-2.4.0 lib/fresh_connection/extend/ar_abstract_adapter.rb
fresh_connection-2.4.0.rc4 lib/fresh_connection/extend/ar_abstract_adapter.rb
fresh_connection-2.4.0.rc3 lib/fresh_connection/extend/ar_abstract_adapter.rb
fresh_connection-2.4.0.rc1 lib/fresh_connection/extend/ar_abstract_adapter.rb