Module: MrDarcy::Promise

Defined in:
lib/mr_darcy/promise.rb,
lib/mr_darcy/promise/em.rb,
lib/mr_darcy/promise/dsl.rb,
lib/mr_darcy/promise/base.rb,
lib/mr_darcy/promise/state.rb,
lib/mr_darcy/promise/thread.rb,
lib/mr_darcy/promise/celluloid.rb,
lib/mr_darcy/promise/collection.rb,
lib/mr_darcy/promise/state/base.rb,
lib/mr_darcy/promise/synchronous.rb,
lib/mr_darcy/promise/child_promise.rb,
lib/mr_darcy/promise/state/rejected.rb,
lib/mr_darcy/promise/state/resolved.rb,
lib/mr_darcy/promise/state/unresolved.rb

Defined Under Namespace

Modules: State Classes: Base, Celluloid, ChildPromise, Collection, DSL, EM, Synchronous, Thread

Class Method Summary collapse

Class Method Details

.new(opts = {}, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mr_darcy/promise.rb', line 17

def new opts={}, &block
  driver = opts[:driver] || ::MrDarcy.driver
  case driver
  when :thread, :Thread
    ::MrDarcy::Promise::Thread.new block
  when :synchronous, :Synchronous
    ::MrDarcy::Promise::Synchronous.new block
  when :celluloid, :Celluloid
    ::MrDarcy::Promise::Celluloid.new block
  when :em, :EM, :event_machine, :eventmachine, :EventMachine
    ::MrDarcy::Promise::EM.new block
  else
    raise "Unknown driver #{driver}"
  end
end