Sha256: 673175b270afc596b9597611a62097a682a65ac4c09bda933146a4ff8a31f8f2

Contents?: true

Size: 522 Bytes

Versions: 5

Compression:

Stored size: 522 Bytes

Contents

class ThinkingSphinx::Callbacks
  attr_reader :instance

  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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/callbacks.rb