Class: ThinkingSphinx::ActiveRecord::Interpreter

Inherits:
Core::Interpreter show all
Defined in:
lib/thinking_sphinx/active_record/interpreter.rb

Instance Method Summary collapse

Methods inherited from Core::Interpreter

#initialize, translate!

Constructor Details

This class inherits a constructor from ThinkingSphinx::Core::Interpreter

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



4
5
6
7
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 4

def define_source(&block)
  @source = @index.append_source
  instance_eval &block
end

#group_by(*columns) ⇒ Object



9
10
11
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 9

def group_by(*columns)
  __source.groupings += columns
end

#has(*columns) ⇒ Object



13
14
15
16
17
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 13

def has(*columns)
  __source.attributes += build_properties(
    ::ThinkingSphinx::ActiveRecord::Attribute, columns
  )
end

#indexes(*columns) ⇒ Object



19
20
21
22
23
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 19

def indexes(*columns)
  __source.fields += build_properties(
    ::ThinkingSphinx::ActiveRecord::Field, columns
  )
end

#join(*columns) ⇒ Object



25
26
27
28
29
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 25

def join(*columns)
  __source.associations += columns.collect { |column|
    ::ThinkingSphinx::ActiveRecord::Association.new column
  }
end

#polymorphs(column, options) ⇒ Object



31
32
33
34
35
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 31

def polymorphs(column, options)
  __source.polymorphs << ::ThinkingSphinx::ActiveRecord::Polymorpher.new(
    __source, column, options[:to]
  )
end

#sanitize_sql(*arguments) ⇒ Object



37
38
39
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 37

def sanitize_sql(*arguments)
  __source.model.send :sanitize_sql, *arguments
end

#set_property(properties) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 41

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)
  end
end

#where(*conditions) ⇒ Object



49
50
51
# File 'lib/thinking_sphinx/active_record/interpreter.rb', line 49

def where(*conditions)
  __source.conditions += conditions
end