Sha256: a730adf065e3e6af3b75effb75d74b6a5c0cdfafaaf80314478277ea04db506e

Contents?: true

Size: 686 Bytes

Versions: 5

Compression:

Stored size: 686 Bytes

Contents

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

  callbacks :after_destroy

  def after_destroy
    indices.each do |index|
      connection.execute Riddle::Query.update(
        index.name, index.document_id_for_key(instance.id),
        :sphinx_deleted => true
      )
    end
  rescue Mysql2::Error => error
    # This isn't vital, so don't raise the error.
  end

  private

  def config
    ThinkingSphinx::Configuration.instance
  end

  def connection
    @connection ||= ThinkingSphinx::Connection.new
  end

  def indices
    config.preload_indices
    config.indices_for_references instance.class.name.underscore.to_sym
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.3 lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
thinking-sphinx-3.0.2 lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
thinking-sphinx-3.0.1 lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
thinking-sphinx-3.0.0 lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
thinking-sphinx-3.0.0.rc lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb