Class: Roby::Promise::Null

Inherits:
Object show all
Defined in:
lib/roby/promise.rb

Overview

A null object for Roby::Promise

Instance Method Summary collapse

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

#beforeObject

Raises:

  • (NullPromise)


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

Returns:

  • (Boolean)


378
379
380
# File 'lib/roby/promise.rb', line 378

def complete?
    true
end

#empty?Boolean

Returns:

  • (Boolean)


342
343
344
# File 'lib/roby/promise.rb', line 342

def empty?
    true
end

#executeObject



366
367
368
# File 'lib/roby/promise.rb', line 366

def execute
    self
end

#failObject

Raises:

  • (NullPromise)


362
363
364
# File 'lib/roby/promise.rb', line 362

def fail(*)
    raise NullPromise, "a null promise cannot fail"
end

#fulfilled?Boolean

Returns:

  • (Boolean)


382
383
384
# File 'lib/roby/promise.rb', line 382

def fulfilled?
    true
end

#null?Boolean

Returns:

  • (Boolean)


338
339
340
# File 'lib/roby/promise.rb', line 338

def null?
    true
end

#on_errorObject

Raises:

  • (NullPromise)


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_successObject

Raises:

  • (NullPromise)


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

Returns:

  • (Boolean)


374
375
376
# File 'lib/roby/promise.rb', line 374

def pending?
    false
end

#reasonObject



400
# File 'lib/roby/promise.rb', line 400

def reason; end

#rejected?Boolean

Returns:

  • (Boolean)


386
387
388
# File 'lib/roby/promise.rb', line 386

def rejected?
    false
end

#stateObject



402
403
404
# File 'lib/roby/promise.rb', line 402

def state
    :fulfilled
end

#thenObject

Raises:

  • (NullPromise)


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

Returns:

  • (Boolean)


370
371
372
# File 'lib/roby/promise.rb', line 370

def unscheduled?
    false
end

#valueObject



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

#waitObject



390
# File 'lib/roby/promise.rb', line 390

def wait; end