Class: MrDarcy::Promise::State::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mr_darcy/promise/state/base.rb

Overview

Abstract base class for all Promise states.

Direct Known Subclasses

Rejected, Resolved, Unresolved

Instance Method Summary collapse

Constructor Details

#initialize(stateful) ⇒ Base

Returns a new instance of Base



6
7
8
# File 'lib/mr_darcy/promise/state/base.rb', line 6

def initialize stateful
  @stateful = stateful
end

Instance Method Details

#rejectObject

Raises:

  • (RuntimeError)


26
27
28
# File 'lib/mr_darcy/promise/state/base.rb', line 26

def reject
  raise RuntimeError, "Cant reject from #{get_state} state"
end

#rejected?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/mr_darcy/promise/state/base.rb', line 18

def rejected?
  false
end

#resolveObject

Raises:

  • (RuntimeError)


22
23
24
# File 'lib/mr_darcy/promise/state/base.rb', line 22

def resolve
  raise RuntimeError, "Can't resolve from #{get_state} state"
end

#resolved?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/mr_darcy/promise/state/base.rb', line 14

def resolved?
  false
end

#unresolved?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/mr_darcy/promise/state/base.rb', line 10

def unresolved?
  false
end