Class: ThinkingSphinx::RealTime::Transcriber

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/real_time/transcriber.rb

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ Transcriber



2
3
4
# File 'lib/thinking_sphinx/real_time/transcriber.rb', line 2

def initialize(index)
  @index = index
end

Instance Method Details

#copy(instance) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/thinking_sphinx/real_time/transcriber.rb', line 6

def copy(instance)
  return unless instance.persisted? && copy?(instance)

  columns, values = ['id'], [index.document_id_for_key(instance.id)]
  (index.fields + index.attributes).each do |property|
    columns << property.name
    values  << property.translate(instance)
  end

  insert = Riddle::Query::Insert.new index.name, columns, values
  sphinxql = insert.replace!.to_sql
  
  ThinkingSphinx::Logger.log :query, sphinxql do
    ThinkingSphinx::Connection.take do |connection|
      connection.execute sphinxql
    end 
  end
end