class ThinkingSphinx::Configuration::MinimumFields

Attributes

indices[R]

Public Class Methods

new(indices) click to toggle source
# File lib/thinking_sphinx/configuration/minimum_fields.rb, line 2
def initialize(indices)
  @indices = indices
end

Public Instance Methods

reconcile() click to toggle source
# File lib/thinking_sphinx/configuration/minimum_fields.rb, line 6
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 Instance Methods

field_collections() click to toggle source
# File lib/thinking_sphinx/configuration/minimum_fields.rb, line 20
def field_collections
  indices_of_type('plain').collect(&:sources).flatten +
  indices_of_type('rt')
end
indices_of_type(type) click to toggle source
# File lib/thinking_sphinx/configuration/minimum_fields.rb, line 25
def indices_of_type(type)
  indices.select { |index| index.type == type }
end
no_inheritance_columns?() click to toggle source
# File lib/thinking_sphinx/configuration/minimum_fields.rb, line 29
def no_inheritance_columns?
  indices.select { |index|
    index.model.table_exists? &&
    index.model.column_names.include?(index.model.inheritance_column)
  }.empty?
end