Class: ThinkingSphinx::RealTime::Index

Inherits:
Riddle::Configuration::RealtimeIndex
  • Object
show all
Includes:
Core::Index
Defined in:
lib/thinking_sphinx/real_time/index.rb

Defined Under Namespace

Classes: Template

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Core::Index

#delta?, #distributed?, #document_id_for_instance, #document_id_for_key, #interpret_definition!, #model, #options, #primary_key, #render

Constructor Details

#initialize(reference, options = {}) ⇒ Index

Returns a new instance of Index.



8
9
10
11
12
13
14
15
16
# 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

Instance Attribute Details

#attributesObject



30
31
32
33
34
# File 'lib/thinking_sphinx/real_time/index.rb', line 30

def attributes
  interpret_definition!

  @attributes
end

#conditionsObject



36
37
38
39
40
# File 'lib/thinking_sphinx/real_time/index.rb', line 36

def conditions
  interpret_definition!

  @conditions
end

#fieldsObject



46
47
48
49
50
# File 'lib/thinking_sphinx/real_time/index.rb', line 46

def fields
  interpret_definition!

  @fields
end

#scopeObject



52
53
54
# File 'lib/thinking_sphinx/real_time/index.rb', line 52

def scope
  @scope.nil? ? model : @scope.call
end

Instance Method Details

#add_attribute(attribute) ⇒ Object



18
19
20
21
22
# File 'lib/thinking_sphinx/real_time/index.rb', line 18

def add_attribute(attribute)
  @attributes.delete_if { |existing| existing.name == attribute.name }

  @attributes << attribute
end

#add_field(field) ⇒ Object



24
25
26
27
28
# File 'lib/thinking_sphinx/real_time/index.rb', line 24

def add_field(field)
  @fields.delete_if { |existing| existing.name == field.name }

  @fields << field
end

#facetsObject



42
43
44
# File 'lib/thinking_sphinx/real_time/index.rb', line 42

def facets
  properties.select(&:facet?)
end

#unique_attribute_namesObject



56
57
58
# File 'lib/thinking_sphinx/real_time/index.rb', line 56

def unique_attribute_names
  attributes.collect(&:name)
end