Class: ThinkingSphinx::Processor

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

Instance Method Summary collapse

Constructor Details

#initialize(instance: nil, model: nil, id: nil) ⇒ Processor

Returns a new instance of Processor.

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
# File 'lib/thinking_sphinx/processor.rb', line 4

def initialize(instance: nil, model: nil, id: nil)
  raise ArgumentError if instance.nil? && (model.nil? || id.nil?)

  @instance = instance
  @model = model || instance.class
  @id = id
end

Instance Method Details

#deleteObject



12
13
14
15
16
17
18
19
20
# File 'lib/thinking_sphinx/processor.rb', line 12

def delete
  return if instance&.new_record?

  indices.each { |index|
    ThinkingSphinx::Deletion.perform(
      index, id || instance.public_send(index.primary_key)
    )
  }
end

#upsertObject



22
23
24
25
26
# File 'lib/thinking_sphinx/processor.rb', line 22

def upsert
  real_time_indices.each do |index|
    ThinkingSphinx::RealTime::Transcriber.new(index).copy loaded_instance
  end
end