Sha256: 41bc0e3cba9e3416555abfacb6a6f1df13c9945b5bf01fb16332536cc669316d

Contents?: true

Size: 814 Bytes

Versions: 5

Compression:

Stored size: 814 Bytes

Contents

# frozen_string_literal: true

module FreshConnection
  module Extend
    module ArResolver
      def spec(*args)
        specification = super

        case specification.config[:adapter].to_s
        when "mysql2"
          require 'fresh_connection/extend/adapters/m2_adapter'
          __extend_adapter_by_fc(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, M2Adapter)
        when "postgresql"
          require 'fresh_connection/extend/adapters/pg_adapter'
          __extend_adapter_by_fc(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, PgAdapter)
        end

        specification
      end

      def __extend_adapter_by_fc(klass, extend_adapter)
        return if klass.include?(extend_adapter)
        klass.prepend BaseAdapter
        klass.prepend extend_adapter
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fresh_connection-3.0.2 lib/fresh_connection/extend/ar_resolver.rb
fresh_connection-3.0.2.rc1 lib/fresh_connection/extend/ar_resolver.rb
fresh_connection-3.0.1 lib/fresh_connection/extend/ar_resolver.rb
fresh_connection-3.0.1.rc2 lib/fresh_connection/extend/ar_resolver.rb
fresh_connection-3.0.1.rc1 lib/fresh_connection/extend/ar_resolver.rb