Sha256: 2faffe01afa202a7ba2fb78de0d171ed97579d730e1636f14a1ff1ec10ec1b02

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

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

  callbacks :after_destroy

  def after_destroy
    indices.each do |index|
      connection.query 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 ||= config.connection
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

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