Class: ThinkingSphinx::Processor
- Inherits:
-
Object
- Object
- ThinkingSphinx::Processor
- Defined in:
- lib/thinking_sphinx/processor.rb
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(instance: nil, model: nil, id: nil) ⇒ Processor
constructor
A new instance of Processor.
-
#sync ⇒ Object
Will upsert or delete instance into all matching indices based on index scope.
-
#upsert ⇒ Object
Will insert instance into all matching indices.
Constructor Details
#initialize(instance: nil, model: nil, id: nil) ⇒ Processor
Returns a new instance of Processor.
7 8 9 10 11 12 13 |
# File 'lib/thinking_sphinx/processor.rb', line 7 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
#delete ⇒ Object
15 16 17 18 19 |
# File 'lib/thinking_sphinx/processor.rb', line 15 def delete return if instance&.new_record? indices.each { |index| perform_deletion(index) } end |
#sync ⇒ Object
Will upsert or delete instance into all matching indices based on index scope
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/thinking_sphinx/processor.rb', line 30 def sync real_time_indices.each do |index| found = find_in(index) if found ThinkingSphinx::RealTime::Transcriber.new(index).copy found else ThinkingSphinx::Deletion.perform(index, index_id(index)) end end end |
#upsert ⇒ Object
Will insert instance into all matching indices
22 23 24 25 26 27 |
# File 'lib/thinking_sphinx/processor.rb', line 22 def upsert real_time_indices.each do |index| found = loaded_instance(index) ThinkingSphinx::RealTime::Transcriber.new(index).copy found if found end end |