Sha256: edc057a97e9e6f86450b54f37c6fe1277ee87aae44a8990b4517e5ed8628c513

Contents?: true

Size: 785 Bytes

Versions: 14

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::Configuration::MinimumFields
  def initialize(indices)
    @indices = indices
  end

  def reconcile
    return unless no_inheritance_columns?

    field_collections.each do |collection|
      collection.fields.delete_if do |field|
        field.name == 'sphinx_internal_class_name'
      end
    end
  end

  private

  attr_reader :indices

  def field_collections
    indices_of_type('plain').collect(&:sources).flatten +
    indices_of_type('rt')
  end

  def indices_of_type(type)
    indices.select { |index| index.type == type }
  end

  def no_inheritance_columns?
    indices.select { |index|
      index.model.table_exists? &&
      index.model.column_names.include?(index.model.inheritance_column)
    }.empty?
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
thinking-sphinx-5.4.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/configuration/minimum_fields.rb