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.
299 300 301 302 |
# File 'lib/roby/promise.rb', line 299 def initialize(value = nil) @creation_time = Time.now @value = value end |
Instance Method Details
#add_observer(&block) ⇒ Object
326 327 328 |
# File 'lib/roby/promise.rb', line 326 def add_observer(&block) block.call(@creation_time, value, nil) end |
#before ⇒ Object
307 |
# File 'lib/roby/promise.rb', line 307 def before(*); raise NullPromise, "attempting to add a step on a null promise" end |
#complete? ⇒ Boolean
316 |
# File 'lib/roby/promise.rb', line 316 def complete?; true end |
#empty? ⇒ Boolean
305 |
# File 'lib/roby/promise.rb', line 305 def empty?; true end |
#execute ⇒ Object
313 |
# File 'lib/roby/promise.rb', line 313 def execute; self end |
#fail ⇒ Object
312 |
# File 'lib/roby/promise.rb', line 312 def fail(*); raise NullPromise, "a null promise cannot fail" end |
#fulfilled? ⇒ Boolean
317 |
# File 'lib/roby/promise.rb', line 317 def fulfilled?; true end |
#null? ⇒ Boolean
304 |
# File 'lib/roby/promise.rb', line 304 def null?; true end |
#on_error ⇒ Object
309 |
# File 'lib/roby/promise.rb', line 309 def on_error(*); raise NullPromise, "attempting to add a step on a null promise" end |
#on_success ⇒ Object
308 |
# File 'lib/roby/promise.rb', line 308 def on_success(*); raise NullPromise, "attempting to add a step on a null promise" end |
#pending? ⇒ Boolean
315 |
# File 'lib/roby/promise.rb', line 315 def pending?; false end |
#reason ⇒ Object
323 |
# File 'lib/roby/promise.rb', line 323 def reason; end |
#rejected? ⇒ Boolean
318 |
# File 'lib/roby/promise.rb', line 318 def rejected?; false end |
#state ⇒ Object
324 |
# File 'lib/roby/promise.rb', line 324 def state; :fulfilled end |
#then ⇒ Object
310 |
# File 'lib/roby/promise.rb', line 310 def then(*); raise NullPromise, "attempting to add a step on a null promise" end |
#unscheduled? ⇒ Boolean
314 |
# File 'lib/roby/promise.rb', line 314 def unscheduled?; false end |
#value ⇒ Object
321 |
# File 'lib/roby/promise.rb', line 321 def value(*); @value end |
#value! ⇒ Object
322 |
# File 'lib/roby/promise.rb', line 322 def value!(*); @value end |
#wait ⇒ Object
319 |
# File 'lib/roby/promise.rb', line 319 def wait; end |