Class: ThinkingSphinx::RealTime::Transcriber

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

Defined Under Namespace

Classes: TranscribeInstance

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ Transcriber

Returns a new instance of Transcriber



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

def initialize(index)
  @index = index
end

Instance Method Details

#copy(*instances) ⇒ Object



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

def copy(*instances)
  items = instances.select { |instance|
    instance.persisted? && copy?(instance)
  }
  return unless items.present?

  values = items.collect { |instance|
    TranscribeInstance.call(instance, index, properties)
  }

  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