Sha256: ebcca474435257edd82df7b2b7f586cc8c750478707226e62605304db60689c5

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

class JSONColumn
  include ActiveRecord::ConnectionAdapters

  def self.call
    new.call
  end

  def call
    postgresql? && column?
  end

  private

  def column?
    (
      ActiveRecord::ConnectionAdapters.constants.include?(:PostgreSQLAdapter) &&
      PostgreSQLAdapter.constants.include?(:TableDefinition) &&
      PostgreSQLAdapter::TableDefinition.instance_methods.include?(:json)
    ) || (
      ActiveRecord::ConnectionAdapters.constants.include?(:PostgreSQL) &&
      PostgreSQL.constants.include?(:ColumnMethods) &&
      PostgreSQL::ColumnMethods.instance_methods.include?(:json)
    )
  end

  def postgresql?
    ENV['DATABASE'] == 'postgresql'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinking-sphinx-3.2.0 spec/support/json_column.rb