Module: ThinkingSphinx::Deltas

Defined in:
lib/thinking_sphinx/deltas.rb,
lib/thinking_sphinx/deltas/default_delta.rb

Defined Under Namespace

Classes: DefaultDelta

Class Method Summary collapse

Class Method Details

.parse(index) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/thinking_sphinx/deltas.rb', line 5

def self.parse(index)
  delta_option = index.local_options.delete(:delta)
  case delta_option
  when TrueClass, :default
    DefaultDelta.new index, index.local_options
  when :delayed
    DelayedDelta.new index, index.local_options
  when :datetime
    DatetimeDelta.new index, index.local_options
  when FalseClass, nil
    nil
  else
    if delta_option.is_a?(String)
      delta_option = Kernel.const_get(delta_option)
    end
    if delta_option.ancestors.include?(ThinkingSphinx::Deltas::DefaultDelta)
      delta_option.new index, index.local_options
    else
      raise "Unknown delta type"
    end
  end
end