Sha256: 76c373f120486f398acc7939e5e96aeca8fc0c2166824f2fa64d8e96cb783b74

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

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