Sha256: e63d046e5a8169b7d13ef106af3851473a09f94978fb66950d1a8ce67893abb0

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

# frozen_string_literal: true

module FreshConnection
  module CheckAdapter
    def self.check(klass)
      if mysql?(klass)
        :mysql
      elsif postgresql?(klass)
        :postgresql
      else
        nil
      end
    end

    def self.mysql?(klass)
      return false unless defined?(::ActiveRecord::ConnectionAdapters::Mysql2Adapter)
      klass == ::ActiveRecord::ConnectionAdapters::Mysql2Adapter
    end

    def self.postgresql?(klass)
      return false unless defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
      klass == ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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