Class: Letterbox::Exchange

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Celluloid
Defined in:
lib/letterbox/exchange.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit_of_work) ⇒ Exchange

Returns a new instance of Exchange.



15
16
17
18
# File 'lib/letterbox/exchange.rb', line 15

def initialize(unit_of_work)
  @unit_of_work = unit_of_work
  @directory    = Directory.new
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



13
14
15
# File 'lib/letterbox/exchange.rb', line 13

def directory
  @directory
end

#unit_of_workObject (readonly)

Returns the value of attribute unit_of_work.



13
14
15
# File 'lib/letterbox/exchange.rb', line 13

def unit_of_work
  @unit_of_work
end

Instance Method Details

#dispatch(payload, address) ⇒ Object



20
21
22
23
24
# File 'lib/letterbox/exchange.rb', line 20

def dispatch(payload, address)
  directory.send_to(address) {
    Address.new_link(Actor.current, unit_of_work)
  }.async.process(payload)
end