class ThinkingSphinx::Source

Attributes

attributes[RW]
base[R]
conditions[RW]
database_configuration[R]
fields[RW]
groupings[RW]
index[R]
joins[RW]
model[RW]
options[RW]

Public Class Methods

new(index, options = {}) click to toggle source
# File lib/thinking_sphinx/source.rb, line 13
def initialize(index, options = {})
  @index        = index
  @model        = index.model
  @fields       = []
  @attributes   = []
  @joins        = []
  @conditions   = []
  @groupings    = []
  @options      = options
  @associations = {}
  @database_configuration = @model.connection.
    instance_variable_get(:@config).clone

  @base = join_dependency_class.new(
    @model, [], initial_joins
  )

  add_internal_attributes_and_facets
end

Public Instance Methods

association(key) click to toggle source

Gets the association stack for a specific key.

# File lib/thinking_sphinx/source.rb, line 72
def association(key)
  @associations[key] ||= Association.children(@model, key)
end
delta?() click to toggle source
# File lib/thinking_sphinx/source.rb, line 66
def delta?
  !@index.delta_object.nil?
end
name() click to toggle source
# File lib/thinking_sphinx/source.rb, line 33
def name
  index.name
end
to_riddle_for_core(offset, position) click to toggle source
# File lib/thinking_sphinx/source.rb, line 37
def to_riddle_for_core(offset, position)
  source = Riddle::Configuration::SQLSource.new(
    "#{index.core_name}_#{position}", adapter.sphinx_identifier
  )

  set_source_database_settings  source
  set_source_fields             source
  set_source_attributes         source, offset
  set_source_settings           source
  set_source_sql                source, offset

  source
end
to_riddle_for_delta(offset, position) click to toggle source
# File lib/thinking_sphinx/source.rb, line 51
def to_riddle_for_delta(offset, position)
  source = Riddle::Configuration::SQLSource.new(
    "#{index.delta_name}_#{position}", adapter.sphinx_identifier
  )
  source.parent = "#{index.core_name}_#{position}"

  set_source_database_settings  source
  set_source_fields             source
  set_source_attributes         source, offset, true
  set_source_settings           source
  set_source_sql                source, offset, true

  source
end