Sha256: dd1c714a7b14467dacb29ceee5ffec067391107014fa0e4df52e2f90cef75d5b

Contents?: true

Size: 553 Bytes

Versions: 8

Compression:

Stored size: 553 Bytes

Contents

# frozen_string_literal: true

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

8 entries across 8 versions & 1 rubygems

Version Path
thinking-sphinx-4.4.1 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/callbacks.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/callbacks.rb