Class: Synapse::Serialization::SerializationAwareEventMessage
- Inherits:
-
Object
- Object
- Synapse::Serialization::SerializationAwareEventMessage
show all
- Extended by:
- Forwardable
- Includes:
- SerializationAware
- Defined in:
- lib/synapse/serialization/message/serialization_aware_message.rb
Overview
Decorator for an event message that adds serialization awareness
Any serialization that occurs on the metadata or payload of this message will be cached so that if a message is serialized more than once, the serialization process will only occur once.
Class Method Summary
collapse
Instance Method Summary
collapse
#serialize_metadata, #serialize_payload
Constructor Details
#initialize(message) ⇒ undefined
24
25
26
27
|
# File 'lib/synapse/serialization/message/serialization_aware_message.rb', line 24
def initialize(message)
@message = message
@cache = SerializedObjectCache.new message
end
|
Class Method Details
14
15
16
17
18
19
20
|
# File 'lib/synapse/serialization/message/serialization_aware_message.rb', line 14
def self.decorate(message)
if message.is_a? SerializationAware
return message
end
self.new message
end
|
Instance Method Details
32
33
34
35
36
37
38
39
|
# File 'lib/synapse/serialization/message/serialization_aware_message.rb', line 32
def and_metadata(additional_metadata)
new_message = @message.and_metadata additional_metadata
if new_message.equal? @message
return self
end
self.class.new new_message
end
|
44
45
46
47
48
49
50
51
|
# File 'lib/synapse/serialization/message/serialization_aware_message.rb', line 44
def with_metadata(replacement_metadata)
new_message = @message.with_metadata replacement_metadata
if new_message.equal? @message
return self
end
self.class.new new_message
end
|