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.



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

#beforeObject

Raises:

  • (NullPromise)


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

def before(*); raise NullPromise, "attempting to add a step on a null promise" end

#complete?Boolean

Returns:

  • (Boolean)


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

def complete?; true end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?; true end

#executeObject



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

def execute; self end

#failObject

Raises:

  • (NullPromise)


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

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

#fulfilled?Boolean

Returns:

  • (Boolean)


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

def fulfilled?; true end

#null?Boolean

Returns:

  • (Boolean)


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

def null?; true end

#on_errorObject

Raises:

  • (NullPromise)


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

def on_error(*); raise NullPromise, "attempting to add a step on a null promise" end

#on_successObject

Raises:

  • (NullPromise)


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

Returns:

  • (Boolean)


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

def pending?; false end

#reasonObject



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

def reason; end

#rejected?Boolean

Returns:

  • (Boolean)


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

def rejected?; false end

#stateObject



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

def state; :fulfilled end

#thenObject

Raises:

  • (NullPromise)


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

def then(*); raise NullPromise, "attempting to add a step on a null promise" end

#unscheduled?Boolean

Returns:

  • (Boolean)


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

def unscheduled?; false end

#valueObject



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

#waitObject



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

def wait; end