Sha256: b35c09bb0a2c793591183baf27c75c44d1501cfda3528c08462a97dfb31cc7d4

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

module FreshConnection
  module CheckAdapter
    class << self
      def check(klass)
        if mysql?(klass)
          :mysql
        elsif postgresql?(klass)
          :postgresql
        end
      end

      def mysql?(klass)
        if defined?(::ActiveRecord::ConnectionAdapters::Mysql2Adapter)
          klass == ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
        else
          false
        end
      end

      def postgresql?(klass)
        if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
          klass == ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
        else
          false
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fresh_connection-3.0.0 lib/fresh_connection/check_adapter.rb
fresh_connection-3.0.0.rc2 lib/fresh_connection/check_adapter.rb