Class: MrDarcy::Promise::Celluloid

Inherits:
Base
  • Object
show all
Defined in:
lib/mr_darcy/promise/celluloid.rb

Overview

A specialisation of MrDarcy::Promise::Base to work with Celluloid.

See MrDarcy::Promise::Base for method information.

Defined Under Namespace

Classes: Actor

Instance Method Summary collapse

Methods inherited from Base

#fail, #raise, #then

Constructor Details

#initialize(*args) ⇒ Celluloid


49
50
51
52
53
54
55
# File 'lib/mr_darcy/promise/celluloid.rb', line 49

def initialize *args
  @complete = false
  ensure_actor
  actor.on_success proc { |v| do_resolve v }
  actor.on_failure proc { |v| do_reject v }
  super
end

Instance Method Details

#finalObject


72
73
74
75
# File 'lib/mr_darcy/promise/celluloid.rb', line 72

def final
  wait_until_complete
  self
end

#reject(value) ⇒ Object


62
63
64
65
# File 'lib/mr_darcy/promise/celluloid.rb', line 62

def reject value
  actor.async.set_status :failure, value
  self
end

#resolve(value) ⇒ Object


57
58
59
60
# File 'lib/mr_darcy/promise/celluloid.rb', line 57

def resolve value
  actor.async.set_status :success, value
  self
end

#resultObject


67
68
69
70
# File 'lib/mr_darcy/promise/celluloid.rb', line 67

def result
  wait_until_complete
  value
end