Class: FlyingSphinx::ResqueDelta

Inherits:
ThinkingSphinx::Deltas::ResqueDelta show all
Defined in:
lib/flying_sphinx/resque_delta.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ThinkingSphinx::Deltas::ResqueDelta

clear!, clear_thinking_sphinx_queues, lock, locked?, prepare_for_core_index, unlock

Class Method Details

.job_prefixObject



11
12
13
# File 'lib/flying_sphinx/resque_delta.rb', line 11

def self.job_prefix
  'fs-delta'
end

.job_typesObject



4
5
6
7
8
9
# File 'lib/flying_sphinx/resque_delta.rb', line 4

def self.job_types
  [
    FlyingSphinx::ResqueDelta::DeltaJob,
    FlyingSphinx::ResqueDelta::FlagAsDeletedJob
  ]
end

Instance Method Details

#index(model, instance = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/flying_sphinx/resque_delta.rb', line 15

def index(model, instance = nil)
  return true if skip?(instance)
  
  model.delta_index_names.each do |delta|
    next if self.class.locked?(delta)
    
    Resque.enqueue(
      FlyingSphinx::ResqueDelta::DeltaJob,
      [delta]
    )
  end
  
  Resque.enqueue(
    FlyingSphinx::ResqueDelta::FlagAsDeletedJob,
    model.core_index_names,
    instance.sphinx_document_id
  ) if instance
  
  true
end