Class: EventMachine::Beanstalk::Defer

Inherits:
EM::DefaultDeferrable
  • Object
show all
Defined in:
lib/em-beanstalk/defer.rb

Instance Method Summary collapse

Constructor Details

#initialize(default_error_callback, &block) ⇒ Defer

Returns a new instance of Defer.



4
5
6
7
8
# File 'lib/em-beanstalk/defer.rb', line 4

def initialize(default_error_callback, &block)
  @error = default_error_callback
  callback(&block) if block
  errback{|message| @error.call(message)}
end

Instance Method Details

#on_error(&block) ⇒ Object



10
11
12
13
# File 'lib/em-beanstalk/defer.rb', line 10

def on_error(&block)
  @error = block
  self
end

#on_success(&block) ⇒ Object



15
16
17
18
# File 'lib/em-beanstalk/defer.rb', line 15

def on_success(&block)
  callback(&block)
  self
end