class ThinkingSphinx::Index
Attributes
block[R]
options[R]
reference[R]
Public Class Methods
define(reference, options = {}, &block)
click to toggle source
# File lib/thinking_sphinx/index.rb, line 4 def self.define(reference, options = {}, &block) new(reference, options, &block).indices.each do |index| ThinkingSphinx::Configuration.instance.indices << index end end
new(reference, options, &block)
click to toggle source
# File lib/thinking_sphinx/index.rb, line 10 def initialize(reference, options, &block) defaults = ThinkingSphinx::Configuration.instance. settings['index_options'] || {} defaults.symbolize_keys! @reference, @options, @block = reference, defaults.merge(options), block end
Public Instance Methods
indices()
click to toggle source
# File lib/thinking_sphinx/index.rb, line 18 def indices options[:delta] ? delta_indices : [single_index] end
Private Instance Methods
delta_indices()
click to toggle source
# File lib/thinking_sphinx/index.rb, line 41 def delta_indices [false, true].collect do |delta| index_class.new( reference, options.merge(:delta? => delta, :delta_processor => processor) ).tap do |index| index.definition_block = block end end end
index_class()
click to toggle source
# File lib/thinking_sphinx/index.rb, line 24 def index_class case options[:with] when :active_record ThinkingSphinx::ActiveRecord::Index when :real_time ThinkingSphinx::RealTime::Index else raise "Unknown index type: #{options[:with]}" end end
processor()
click to toggle source
# File lib/thinking_sphinx/index.rb, line 52 def processor @processor ||= ThinkingSphinx::Deltas.processor_for options.delete(:delta) end
single_index()
click to toggle source
# File lib/thinking_sphinx/index.rb, line 35 def single_index index_class.new(reference, options).tap do |index| index.definition_block = block end end