class ThinkingSphinx::RealTime::Index

Attributes

attributes[W]
conditions[W]
fields[W]
scope[W]

Public Class Methods

new(reference, options = {}) click to toggle source
Calls superclass method ThinkingSphinx::Core::Index::new
# File lib/thinking_sphinx/real_time/index.rb, line 8
def initialize(reference, options = {})
  @fields     = []
  @attributes = []
  @conditions = []

  super reference, options

  Template.new(self).apply
end

Public Instance Methods

add_attribute(attribute) click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 18
def add_attribute(attribute)
  @attributes << attribute
end
add_field(field) click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 22
def add_field(field)
  @fields << field
end
attributes() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 26
def attributes
  interpret_definition!

  @attributes
end
conditions() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 32
def conditions
  interpret_definition!

  @conditions
end
facets() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 38
def facets
  properties.select(&:facet?)
end
fields() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 42
def fields
  interpret_definition!

  @fields
end
scope() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 48
def scope
  @scope.nil? ? model : @scope.call
end
unique_attribute_names() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 52
def unique_attribute_names
  attributes.collect(&:name)
end

Private Instance Methods

append_unique_attribute(collection, attribute) click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 58
def append_unique_attribute(collection, attribute)
  collection << attribute.name unless collection.include?(attribute.name)
end
collection_for(attribute) click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 62
def collection_for(attribute)
  case attribute.type
  when :integer, :boolean
    attribute.multi? ? @rt_attr_multi : @rt_attr_uint
  when :string
    @rt_attr_string
  when :timestamp
    @rt_attr_timestamp
  when :float
    @rt_attr_float
  when :bigint
    attribute.multi? ? @rt_attr_multi_64 : @rt_attr_bigint
  when :json
    @rt_attr_json
  else
    raise "Unknown attribute type '#{attribute.type}'"
  end
end
interpreter() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 81
def interpreter
  ThinkingSphinx::RealTime::Interpreter
end
pre_render() click to toggle source
Calls superclass method ThinkingSphinx::Core::Index#pre_render
# File lib/thinking_sphinx/real_time/index.rb, line 85
def pre_render
  super

  @rt_field = fields.collect &:name

  attributes.each do |attribute|
    append_unique_attribute collection_for(attribute), attribute
  end
end
properties() click to toggle source
# File lib/thinking_sphinx/real_time/index.rb, line 95
def properties
  fields + attributes
end