Sha256: 18c71c62920cf14bcc4b61de05a657b323dc0fc0ee9eddcd48186681ce7217c2
Contents?: true
Size: 1.07 KB
Versions: 8
Compression:
Stored size: 1.07 KB
Contents
class ThinkingSphinx::IndexSet include Enumerable 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 each(&block) indices.each { |index| yield index } end def to_a indices end private 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? return @configuration.indices if @classes.empty? @configuration.indices_for_references(*references) end def references classes_and_ancestors.collect { |klass| klass.name.underscore.to_sym } end end
Version data entries
8 entries across 8 versions & 1 rubygems