Class: ThinkingSphinx::Index
- Inherits:
-
Object
- Object
- ThinkingSphinx::Index
show all
- Defined in:
- lib/thinking_sphinx/index.rb,
lib/thinking_sphinx/index/builder.rb,
lib/thinking_sphinx/index/faux_column.rb
Overview
The Index class is a ruby representation of a Sphinx source (not a Sphinx index - yes, I know it’s a little confusing. You’ll manage). This is another ‘internal’ Thinking Sphinx class - if you’re using it directly, you either know what you’re doing, or messing with things beyond your ken. Enjoy.
Defined Under Namespace
Classes: Builder, FauxColumn
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(model, &block) ⇒ Index
Create a new index instance by passing in the model it is tied to, and a block to build it with (optional but recommended). For documentation on the syntax for inside the block, the Builder class is what you want.
Quick Example:
Index.new(User) do
indexes login, email
has created_at
set_property :delta => true
end
28
29
30
31
32
33
|
# File 'lib/thinking_sphinx/index.rb', line 28
def initialize(model, &block)
@model = model
@sources = []
@options = {}
@delta_object = nil
end
|
Instance Attribute Details
#delta_object ⇒ Object
Returns the value of attribute delta_object.
12
13
14
|
# File 'lib/thinking_sphinx/index.rb', line 12
def delta_object
@delta_object
end
|
#model ⇒ Object
Returns the value of attribute model.
12
13
14
|
# File 'lib/thinking_sphinx/index.rb', line 12
def model
@model
end
|
#sources ⇒ Object
Returns the value of attribute sources.
12
13
14
|
# File 'lib/thinking_sphinx/index.rb', line 12
def sources
@sources
end
|
Class Method Details
.name(model) ⇒ Object
47
48
49
|
# File 'lib/thinking_sphinx/index.rb', line 47
def self.name(model)
model.name.underscore.tr(':/\\', '_')
end
|
Instance Method Details
#attributes ⇒ Object
39
40
41
|
# File 'lib/thinking_sphinx/index.rb', line 39
def attributes
@sources.collect { |source| source.attributes }.flatten
end
|
#delta? ⇒ Boolean
72
73
74
|
# File 'lib/thinking_sphinx/index.rb', line 72
def delta?
!@delta_object.nil?
end
|
#fields ⇒ Object
35
36
37
|
# File 'lib/thinking_sphinx/index.rb', line 35
def fields
@sources.collect { |source| source.fields }.flatten
end
|
#infix_fields ⇒ Object
55
56
57
|
# File 'lib/thinking_sphinx/index.rb', line 55
def infix_fields
fields.select { |field| field.infixes }
end
|
#local_options ⇒ Object
59
60
61
|
# File 'lib/thinking_sphinx/index.rb', line 59
def local_options
@options
end
|
#name ⇒ Object
43
44
45
|
# File 'lib/thinking_sphinx/index.rb', line 43
def name
self.class.name(@model)
end
|
#prefix_fields ⇒ Object
51
52
53
|
# File 'lib/thinking_sphinx/index.rb', line 51
def prefix_fields
fields.select { |field| field.prefixes }
end
|