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

append, callbacks, #initialize, resume!, suspend, suspend!, suspended?

Constructor Details

This class inherits a constructor from ThinkingSphinx::Callbacks

Instance Method Details

#after_commitObject



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

def after_commit
  return unless !suspended? && delta_indices? && toggled?

  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
25
# File 'lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb', line 20

def before_save
  return unless !ThinkingSphinx::Callbacks.suspended? && delta_indices? &&
    new_or_changed?

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