Class: ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks

Inherits:
Callbacks
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb

Instance Attribute Summary

Attributes inherited from Callbacks

#instance

Instance Method Summary collapse

Methods inherited from Callbacks

callbacks, #initialize

Constructor Details

This class inherits a constructor from ThinkingSphinx::Callbacks

Instance Method Details

#after_commitObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb', line 6

def after_commit
  return unless delta_indices? && processors.any? { |processor|
    processor.toggled?(instance)
  } && !ThinkingSphinx::Deltas.suspended?

  delta_indices.each do |index|
    index.delta_processor.index index
  end

  core_indices.each do |index|
    index.delta_processor.delete index, instance
  end
end

#before_saveObject



20
21
22
23
24
# File 'lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb', line 20

def before_save
  return unless delta_indices?

  processors.each { |processor| processor.toggle instance }
end