Class: Synapse::Serialization::MessageSerializer
- Inherits:
-
Object
- Object
- Synapse::Serialization::MessageSerializer
- Extended by:
- Forwardable
- Defined in:
- lib/synapse/serialization/message/serializer.rb
Overview
Serializer that provides convenience methods for serializing messages and adds support for optimizing the serialization process
Instance Method Summary collapse
- #initialize(serializer) ⇒ undefined constructor
-
#serialize_metadata(message, expected_type) ⇒ SerializedObject
Returns the serialized metadata for the given message in the expected type, optimizing the serialization, if possible.
-
#serialize_payload(message, expected_type) ⇒ SerializedObject
Returns the serialized payload for the given message in the expected type, optimizing the serialization, if possible.
Constructor Details
#initialize(serializer) ⇒ undefined
10 11 12 |
# File 'lib/synapse/serialization/message/serializer.rb', line 10 def initialize(serializer) @serializer = serializer end |
Instance Method Details
#serialize_metadata(message, expected_type) ⇒ SerializedObject
Returns the serialized metadata for the given message in the expected type, optimizing the serialization, if possible
20 21 22 23 24 25 26 |
# File 'lib/synapse/serialization/message/serializer.rb', line 20 def (, expected_type) if .is_a? SerializationAware . @serializer, expected_type else serialize ., expected_type end end |
#serialize_payload(message, expected_type) ⇒ SerializedObject
Returns the serialized payload for the given message in the expected type, optimizing the serialization, if possible
34 35 36 37 38 39 40 |
# File 'lib/synapse/serialization/message/serializer.rb', line 34 def serialize_payload(, expected_type) if .is_a? SerializationAware .serialize_payload @serializer, expected_type else serialize .payload, expected_type end end |