Class: ThinkingSphinx::Callbacks

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/callbacks.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance) ⇒ Callbacks

Returns a new instance of Callbacks



30
31
32
# File 'lib/thinking_sphinx/callbacks.rb', line 30

def initialize(instance)
  @instance = instance
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance



2
3
4
# File 'lib/thinking_sphinx/callbacks.rb', line 2

def instance
  @instance
end

Class Method Details

.callbacks(*methods) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/thinking_sphinx/callbacks.rb', line 4

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

.resume!Object



12
13
14
# File 'lib/thinking_sphinx/callbacks.rb', line 12

def self.resume!
  @suspended = false
end

.suspend(&block) ⇒ Object



16
17
18
19
20
# File 'lib/thinking_sphinx/callbacks.rb', line 16

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

.suspend!Object



22
23
24
# File 'lib/thinking_sphinx/callbacks.rb', line 22

def self.suspend!
  @suspended = true
end

.suspended?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/thinking_sphinx/callbacks.rb', line 26

def self.suspended?
  @suspended
end