Class: Roby::Promise::Null
Overview
A null object for Roby::Promise
Instance Method Summary collapse
- #add_observer(&block) ⇒ Object
- #before ⇒ Object
- #complete? ⇒ Boolean
- #empty? ⇒ Boolean
- #execute ⇒ Object
- #fail ⇒ Object
- #fulfilled? ⇒ Boolean
-
#initialize(value = nil) ⇒ Null
constructor
A new instance of Null.
- #null? ⇒ Boolean
- #on_error ⇒ Object
- #on_success ⇒ Object
- #pending? ⇒ Boolean
- #reason ⇒ Object
- #rejected? ⇒ Boolean
- #state ⇒ Object
- #then ⇒ Object
- #unscheduled? ⇒ Boolean
- #value ⇒ Object
- #value! ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(value = nil) ⇒ Null
Returns a new instance of Null.
333 334 335 336 |
# File 'lib/roby/promise.rb', line 333 def initialize(value = nil) @creation_time = Time.now @value = value end |
Instance Method Details
#add_observer(&block) ⇒ Object
406 407 408 |
# File 'lib/roby/promise.rb', line 406 def add_observer(&block) block.call(@creation_time, value, nil) end |
#before ⇒ Object
346 347 348 |
# File 'lib/roby/promise.rb', line 346 def before(*) raise NullPromise, "attempting to add a step on a null promise" end |
#complete? ⇒ Boolean
378 379 380 |
# File 'lib/roby/promise.rb', line 378 def complete? true end |
#empty? ⇒ Boolean
342 343 344 |
# File 'lib/roby/promise.rb', line 342 def empty? true end |
#execute ⇒ Object
366 367 368 |
# File 'lib/roby/promise.rb', line 366 def execute self end |
#fail ⇒ Object
362 363 364 |
# File 'lib/roby/promise.rb', line 362 def fail(*) raise NullPromise, "a null promise cannot fail" end |
#fulfilled? ⇒ Boolean
382 383 384 |
# File 'lib/roby/promise.rb', line 382 def fulfilled? true end |
#null? ⇒ Boolean
338 339 340 |
# File 'lib/roby/promise.rb', line 338 def null? true end |
#on_error ⇒ Object
354 355 356 |
# File 'lib/roby/promise.rb', line 354 def on_error(*) raise NullPromise, "attempting to add a step on a null promise" end |
#on_success ⇒ Object
350 351 352 |
# File 'lib/roby/promise.rb', line 350 def on_success(*) raise NullPromise, "attempting to add a step on a null promise" end |
#pending? ⇒ Boolean
374 375 376 |
# File 'lib/roby/promise.rb', line 374 def pending? false end |
#reason ⇒ Object
400 |
# File 'lib/roby/promise.rb', line 400 def reason; end |
#rejected? ⇒ Boolean
386 387 388 |
# File 'lib/roby/promise.rb', line 386 def rejected? false end |
#state ⇒ Object
402 403 404 |
# File 'lib/roby/promise.rb', line 402 def state :fulfilled end |
#then ⇒ Object
358 359 360 |
# File 'lib/roby/promise.rb', line 358 def then(*) raise NullPromise, "attempting to add a step on a null promise" end |
#unscheduled? ⇒ Boolean
370 371 372 |
# File 'lib/roby/promise.rb', line 370 def unscheduled? false end |
#value ⇒ Object
392 393 394 |
# File 'lib/roby/promise.rb', line 392 def value(*) @value end |
#value! ⇒ Object
396 397 398 |
# File 'lib/roby/promise.rb', line 396 def value!(*) @value end |
#wait ⇒ Object
390 |
# File 'lib/roby/promise.rb', line 390 def wait; end |