Module: DeferrableGratification::Fluent
- Defined in:
- lib/deferrable_gratification/fluent.rb
Overview
Allows JQuery-style fluent syntax for registering several callbacks and errbacks on the same Deferrable. e.g.
DeferrableMonkeyShaver.new(monkey).
callback { puts "Monkey is shaved" }.
callback { monkey.entertain! }.
errback {|e| puts "Unable to shave monkey! #{e}" }.
errback {|_| monkey.terminate! }.
shave
Include this into a class that has already included Deferrable
.
Instance Method Summary collapse
-
#callback(&block) ⇒ Deferrable, Fluent
Register
block
to be called on success. -
#errback(&block) ⇒ Deferrable, Fluent
Register
block
to be called on failure. -
#timeout(seconds) ⇒ Deferrable, Fluent
Ensure that if this Deferrable doesn’t either succeed or fail within the timeout, it will call its errback with no parameters.
Instance Method Details
#callback(&block) ⇒ Deferrable, Fluent
Register block
to be called on success.
19 20 21 22 |
# File 'lib/deferrable_gratification/fluent.rb', line 19 def callback(&block) super(&block) self end |
#errback(&block) ⇒ Deferrable, Fluent
Register block
to be called on failure.
29 30 31 32 |
# File 'lib/deferrable_gratification/fluent.rb', line 29 def errback(&block) super(&block) self end |
#timeout(seconds) ⇒ Deferrable, Fluent
Ensure that if this Deferrable doesn’t either succeed or fail within the timeout, it will call its errback with no parameters.
40 41 42 43 |
# File 'lib/deferrable_gratification/fluent.rb', line 40 def timeout(seconds) super(seconds) self end |