class PromiseApi
@abstract Promise
API
Public Instance Methods
always(fn=nil, &blk)
click to toggle source
Runs then-function call with same function for success and failure @param [Proc] fn Function to handle success or failure @return Result of then-function call
# File lib/bellite.rb, line 568 def always(fn=nil, &blk) return then_(fn||blk, fn||blk) end
done(success, &blk)
click to toggle source
Runs then-function in case of success @param [Proc] success Success handler @return Result of then-function call
# File lib/bellite.rb, line 582 def done(success, &blk) return then_(success||blk,false) end
fail(failure, &blk)
click to toggle source
Runs then-function in case of failure @param [Proc] failure Failure handler @return Result of then-function call
# File lib/bellite.rb, line 575 def fail(failure, &blk) return then_(false, failure||blk) end
then(success=false, failure=false, &blk)
click to toggle source
# 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)
click to toggle source
# 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