Sha256: 9d6ac05281d8ab17e9eaf518fdd906d4229205a6a39f62a7463e91daf26df0c1

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/configuration/minimum_fields.rb