class ThinkingSphinx::RealTime::Index::Template

Attributes

index[R]

Public Class Methods

new(index) click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 6
def initialize(index)
  @index = index
end

Public Instance Methods

apply() click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 10
def apply
  add_field class_column, :sphinx_internal_class_name

  add_attribute primary_key,  :sphinx_internal_id,    :bigint
  add_attribute class_column, :sphinx_internal_class, :string, :facet => true
  add_attribute 0,            :sphinx_deleted,        :integer
end

Private Instance Methods

add_attribute(column, name, type, options = {}) click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 20
def add_attribute(column, name, type, options = {})
  index.add_attribute ThinkingSphinx::RealTime::Attribute.new(
    ThinkingSphinx::ActiveRecord::Column.new(*column),
    options.merge(:as => name, :type => type)
  )
end
add_field(column, name) click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 27
def add_field(column, name)
  index.add_field ThinkingSphinx::RealTime::Field.new(
    ThinkingSphinx::ActiveRecord::Column.new(*column), :as => name
  )
end
class_column() click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 33
def class_column
  [:class, :name]
end
primary_key() click to toggle source
# File lib/thinking_sphinx/real_time/index/template.rb, line 37
def primary_key
  index.primary_key.to_sym
end