Class: ThinkingSphinx::ActiveRecord::Interpreter
Instance Method Summary
collapse
#initialize, translate!
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ThinkingSphinx::Core::Interpreter
Instance Method Details
#define_source(&block) ⇒ Object
6
7
8
9
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 6
def define_source(&block)
@source = @index.append_source
instance_eval &block
end
|
#group_by(*columns) ⇒ Object
11
12
13
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 11
def group_by(*columns)
__source.groupings += columns
end
|
#has(*columns) ⇒ Object
15
16
17
18
19
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 15
def has(*columns)
build_properties(
::ThinkingSphinx::ActiveRecord::Attribute, columns
).each { |attribute| __source.add_attribute attribute }
end
|
#indexes(*columns) ⇒ Object
21
22
23
24
25
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 21
def indexes(*columns)
build_properties(
::ThinkingSphinx::ActiveRecord::Field, columns
).each { |field| __source.add_field field }
end
|
#join(*columns) ⇒ Object
27
28
29
30
31
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 27
def join(*columns)
__source.associations += columns.collect { |column|
::ThinkingSphinx::ActiveRecord::Association.new column
}
end
|
#polymorphs(column, options) ⇒ Object
33
34
35
36
37
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 33
def polymorphs(column, options)
__source.polymorphs << ::ThinkingSphinx::ActiveRecord::Polymorpher.new(
__source, column, options[:to]
)
end
|
#sanitize_sql(*arguments) ⇒ Object
39
40
41
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 39
def sanitize_sql(*arguments)
__source.model.send :sanitize_sql, *arguments
end
|
#set_database(hash_or_key) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 43
def set_database(hash_or_key)
configuration = hash_or_key.is_a?(::Hash) ? hash_or_key :
::ActiveRecord::Base.configurations[hash_or_key.to_s]
__source.set_database_settings configuration.symbolize_keys
end
|
#set_property(properties) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 50
def set_property(properties)
properties.each do |key, value|
@index.send("#{key}=", value) if @index.class.settings.include?(key)
__source.send("#{key}=", value) if __source.class.settings.include?(key)
__source.options[key] = value if source_option?(key)
@index.options[key] = value if search_option?(key)
end
end
|
#where(*conditions) ⇒ Object
59
60
61
|
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 59
def where(*conditions)
__source.conditions += conditions
end
|