Class: ThinkingSphinx::RealTime::Transcriber

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

Instance Method Summary (collapse)

Constructor Details

- (Transcriber) initialize(index)



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

def initialize(index)
  @index = index
end

Instance Method Details

- (Object) copy(instance)



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

def copy(instance)
  return unless 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

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