Class: Async::Bus::Protocol::Wrapper

Inherits:
MessagePack::Factory
  • Object
show all
Defined in:
lib/async/bus/protocol/wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(bus) ⇒ Wrapper

Returns a new instance of Wrapper.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/async/bus/protocol/wrapper.rb', line 29

def initialize(bus)
	super()
	
	@bus = bus
	
	self.register_type(0x00, Object,
		packer: @bus.method(:proxy),
		unpacker: @bus.method(:[])
	)
	
	self.register_type(0x01, Symbol)
	self.register_type(0x02, Exception,
		packer: ->(exception){Marshal.dump(exception)},
		unpacker: ->(data){Marshal.load(data)},
	)
	
	self.register_type(0x03, Class,
		packer: ->(klass){Marshal.dump(klass)},
		unpacker: ->(data){Marshal.load(data)},
	)
end