Sha256: 66bb2e16f8ffb8e5f515310e58eb96480ffa32b9d1ea57b6bb89af3b139d238e

Contents?: true

Size: 848 Bytes

Versions: 9

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::Callbacks
  attr_reader :instance

  def self.append(model, reference = nil, options, &block)
    reference ||= ThinkingSphinx::Configuration.instance.index_set_class.
      reference_name(model)

    ThinkingSphinx::Callbacks::Appender.call(model, reference, options, &block)
  end

  def self.callbacks(*methods)
    mod = Module.new
    methods.each do |method|
      mod.send(:define_method, method) { |instance| new(instance).send(method) }
    end
    extend mod
  end

  def self.resume!
    @suspended = false
  end

  def self.suspend(&block)
    suspend!
    yield
    resume!
  end

  def self.suspend!
    @suspended = true
  end

  def self.suspended?
    @suspended
  end

  def initialize(instance)
    @instance = instance
  end
end

require "thinking_sphinx/callbacks/appender"

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/callbacks.rb