Sha256: 2ed90765ef62aac2fb8a87a2e40c1d18c78362a3d7f255b891cac53c20d6dfa8

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

class ThinkingSphinx::RealTime::Index < Riddle::Configuration::RealtimeIndex
  include ThinkingSphinx::Core::Index

  attr_accessor :fields, :attributes

  def initialize(reference, options = {})
    @fields     = []
    @attributes = []

    Template.new(self).apply

    super reference, options
  end

  def unique_attribute_names
    attributes.collect(&:name)
  end

  private

  def interpreter
    ThinkingSphinx::RealTime::Interpreter
  end

  def pre_render
    super

    @rt_field = fields.collect &:name

    attributes.each do |attribute|
      case attribute.type
      when :integer, :boolean
        @rt_attr_uint << attribute.name unless @rt_attr_uint.include?(attribute.name)
      when :string
        @rt_attr_string << attribute.name unless @rt_attr_string.include?(attribute.name)
      when :timestamp
        @rt_attr_timestamp << attribute.name unless @rt_attr_timestamp.include?(attribute.name)
      when :float
        @rt_attr_float << attribute.name unless @rt_attr_float.include?(attribute.name)
      else
        raise "Unknown attribute type '#{attribute.type(model)}'"
      end
    end
  end
end

require 'thinking_sphinx/real_time/index/template'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.0.rc lib/thinking_sphinx/real_time/index.rb
thinking-sphinx-3.0.0.pre lib/thinking_sphinx/real_time/index.rb