Module: Bones::RPC::Protocol::BinaryHelper
- Included in:
- ExtMessage
- Defined in:
- lib/bones/rpc/protocol/binary_helper.rb
Overview
The base class for building all messages needed to implement the Bones RPC Protocol. It provides a minimal DSL for defining typed fields for serialization and deserialization over the wire.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Extends the including class with
ClassMethods
.
Instance Method Summary collapse
-
#inspect ⇒ String
The nicely formatted version of the message.
-
#receive_replies(connection) ⇒ nil
Default implementation for a message is to do nothing when receiving replies.
-
#serialize(buffer = "", adapter = nil) ⇒ String
(also: #to_s)
Serializes the message and all of its fields to a new buffer or to the provided buffer.
Class Method Details
.included(base) ⇒ Object
Extends the including class with ClassMethods
.
74 75 76 77 |
# File 'lib/bones/rpc/protocol/binary_helper.rb', line 74 def included(base) super base.extend(ClassMethods) end |
Instance Method Details
#inspect ⇒ String
Returns the nicely formatted version of the message.
62 63 64 65 66 67 68 |
# File 'lib/bones/rpc/protocol/binary_helper.rb', line 62 def inspect fields = self.class.fields.map do |field| "@#{field}=" + __send__(field).inspect end "#<#{self.class.name}\n" << " #{fields * "\n "}>" end |
#receive_replies(connection) ⇒ nil
Default implementation for a message is to do nothing when receiving replies.
43 |
# File 'lib/bones/rpc/protocol/binary_helper.rb', line 43 def receive_replies(connection); end |
#serialize(buffer = "", adapter = nil) ⇒ String Also known as: to_s
Serializes the message and all of its fields to a new buffer or to the provided buffer.
56 57 58 |
# File 'lib/bones/rpc/protocol/binary_helper.rb', line 56 def serialize(buffer = "", adapter = nil) raise NotImplementedError, "This method is generated after calling #finalize on a message class" end |