Sha256: b1d79286328281e3a0903d92a0f8a4bdf2e0a294b848e1cee8042a651feda015
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
class ThinkingSphinx::IndexSet include Enumerable delegate :each, :empty?, :to => :indices def initialize(classes, index_names, configuration = nil) @classes = classes || [] @index_names = index_names @configuration = configuration || ThinkingSphinx::Configuration.instance end def ancestors classes_and_ancestors - classes end def to_a indices end private attr_reader :classes, :configuration, :index_names def classes_and_ancestors @classes_and_ancestors ||= classes.collect { |model| model.ancestors.take_while { |klass| klass != ActiveRecord::Base }.select { |klass| klass.class == Class } }.flatten end def indices configuration.preload_indices return configuration.indices.select { |index| index_names.include?(index.name) } if index_names && index_names.any? everything = classes.empty? ? configuration.indices : configuration.indices_for_references(*references) everything.reject &:distributed? end def references classes_and_ancestors.collect { |klass| klass.name.underscore.to_sym } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
thinking-sphinx-3.1.2 | lib/thinking_sphinx/index_set.rb |
thinking-sphinx-3.1.1 | lib/thinking_sphinx/index_set.rb |
thinking-sphinx-3.1.0 | lib/thinking_sphinx/index_set.rb |