Module: Zerg::Support::EventMachine::ObjectProtocol

Includes:
FrameProtocol
Defined in:
lib/zerg_support/event_machine/object_protocol.rb

Overview

Event Machine protocol for sending serializable objects.

Instance Method Summary collapse

Methods included from FrameProtocol

decode_natural, encode_natural, #receive_data, #send_frame

Instance Method Details

#receive_frame(frame_data) ⇒ Object

:nodoc: Processes an incoming frame and de-serializes the object in it.



16
17
18
# File 'lib/zerg_support/event_machine/object_protocol.rb', line 16

def receive_frame(frame_data)
  receive_object YAML.load(frame_data)
end

#receive_object(object) ⇒ Object

Override to process incoming objects.



21
# File 'lib/zerg_support/event_machine/object_protocol.rb', line 21

def receive_object(object); end

#send_object(object) ⇒ Object

Send a serialized object.



11
12
13
# File 'lib/zerg_support/event_machine/object_protocol.rb', line 11

def send_object(object)
  send_frame YAML.dump(object)
end