Sha256: 41c5608ec31e1f2da9721fa4e1ae4cbf275a3fe7f3ae0dd6041b9ed068ef4843

Contents?: true

Size: 905 Bytes

Versions: 3

Compression:

Stored size: 905 Bytes

Contents

require 'thinking_sphinx/deltas/default_delta'
require 'thinking_sphinx/deltas/datetime_delta'

module ThinkingSphinx
  module Deltas
    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
        require 'thinking_sphinx/deltas/delayed_delta'
        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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moneypools-thinking-sphinx-1.2.13 lib/thinking_sphinx/deltas.rb
moneypools-thinking-sphinx-1.2.12 lib/thinking_sphinx/deltas.rb
moneypools-thinking-sphinx-1.2.11 lib/thinking_sphinx/deltas.rb