Sha256: a242081fa82e204317738a3c24f527de3fa29eefe8dd12f72aa8a08b624ec71a

Contents?: true

Size: 615 Bytes

Versions: 2

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks <
  ThinkingSphinx::Callbacks

  callbacks :after_destroy, :after_rollback

  def after_destroy
    delete_from_sphinx
  end

  def after_rollback
    delete_from_sphinx
  end

  private

  def delete_from_sphinx
    return if ThinkingSphinx::Callbacks.suspended? || instance.new_record?

    indices.each { |index|
      ThinkingSphinx::Deletion.perform index, instance.id
    }
  end

  def indices
    ThinkingSphinx::Configuration.instance.index_set_class.new(
      :classes => [instance.class]
    ).to_a
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thinking-sphinx-4.1.0 lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb