Class: PromiseApi Abstract
- Inherits:
-
Object
- Object
- PromiseApi
- Defined in:
- lib/bellite.rb
Overview
This class is abstract.
Promise API
Instance Method Summary collapse
-
#always(fn = nil, &blk) ⇒ Object
Runs then-function call with same function for success and failure.
-
#done(success, &blk) ⇒ Object
Runs then-function in case of success.
-
#fail(failure, &blk) ⇒ Object
Runs then-function in case of failure.
- #then(success = false, failure = false, &blk) ⇒ Object
- #then_(success = false, failure = false, &blk) ⇒ Object
Instance Method Details
#always(fn = nil, &blk) ⇒ Object
Runs then-function call with same function for success and failure
568 569 570 |
# File 'lib/bellite.rb', line 568 def always(fn=nil, &blk) return then_(fn||blk, fn||blk) end |
#done(success, &blk) ⇒ Object
Runs then-function in case of success
582 583 584 |
# File 'lib/bellite.rb', line 582 def done(success, &blk) return then_(success||blk,false) end |
#fail(failure, &blk) ⇒ Object
Runs then-function in case of failure
575 576 577 |
# File 'lib/bellite.rb', line 575 def fail(failure, &blk) return then_(false, failure||blk) end |
#then(success = false, failure = false, &blk) ⇒ Object
586 587 588 |
# File 'lib/bellite.rb', line 586 def then(success=false, failure=false, &blk) return then_(success, failure, &blk) end |
#then_(success = false, failure = false, &blk) ⇒ Object
589 590 591 592 593 594 |
# File 'lib/bellite.rb', line 589 def then_(success=false, failure=false, &blk) if (blk && (success || failure)) raise ArgumentError, "Ambiguous block argument" end return @_then.call(success,failure) end |