Sha256: 7a385f2ca082b26db9f63e232a515dd8e15dc346387094241e3d71a222265365

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

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

  def reconcile
    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
    plain_indices_without_inheritance.collect(&:sources).flatten +
    indices_of_type('rt')
  end

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

  def inheritance_columns?(index)
    index.model.table_exists? && index.model.column_names.include?(index.model.inheritance_column)
  end

  def plain_indices_without_inheritance
    indices_of_type('plain').reject(&method(:inheritance_columns?))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thinking-sphinx-5.5.1 lib/thinking_sphinx/configuration/minimum_fields.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/configuration/minimum_fields.rb