Sha256: 50e5fe43a2a7232e73c627f7bad3ea1d02bf8682c79b4e0e474213a1c891ae9e

Contents?: true

Size: 761 Bytes

Versions: 17

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

class JSONColumn
  include ActiveRecord::ConnectionAdapters

  def self.call
    new.call
  end

  def call
    ruby? && 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

  def ruby?
    RUBY_PLATFORM != 'java'
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 spec/support/json_column.rb
thinking-sphinx-5.5.1 spec/support/json_column.rb
thinking-sphinx-5.5.0 spec/support/json_column.rb
thinking-sphinx-5.4.0 spec/support/json_column.rb
thinking-sphinx-5.3.0 spec/support/json_column.rb
thinking-sphinx-5.2.1 spec/support/json_column.rb
thinking-sphinx-5.2.0 spec/support/json_column.rb
thinking-sphinx-5.1.0 spec/support/json_column.rb
thinking-sphinx-5.0.0 spec/support/json_column.rb
thinking-sphinx-4.4.1 spec/support/json_column.rb
thinking-sphinx-4.4.0 spec/support/json_column.rb
thinking-sphinx-4.3.2 spec/support/json_column.rb
thinking-sphinx-4.3.1 spec/support/json_column.rb
thinking-sphinx-4.3.0 spec/support/json_column.rb
thinking-sphinx-4.2.0 spec/support/json_column.rb
thinking-sphinx-4.1.0 spec/support/json_column.rb
thinking-sphinx-4.0.0 spec/support/json_column.rb