Class: EventStoreClient::Mapper::Default
- Inherits:
-
Object
- Object
- EventStoreClient::Mapper::Default
- Defined in:
- lib/event_store_client/mapper/default.rb
Instance Method Summary collapse
- #deserialize(event_or_raw_event) ⇒ Object
-
#initialize(config:, serializer: Serializer::Json) ⇒ Default
constructor
A new instance of Default.
- #serialize(event) ⇒ EventStoreClient::SerializedEvent
Constructor Details
#initialize(config:, serializer: Serializer::Json) ⇒ Default
Returns a new instance of Default.
13 14 15 16 |
# File 'lib/event_store_client/mapper/default.rb', line 13 def initialize(config:, serializer: Serializer::Json) @serializer = serializer @config = config end |
Instance Method Details
#deserialize(event_or_raw_event) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/event_store_client/mapper/default.rb', line 26 def deserialize(event_or_raw_event, **) return event_or_raw_event if event_or_raw_event.is_a?(EventStoreClient::DeserializedEvent) Serializer::EventDeserializer.call( event_or_raw_event, config: config, serializer: serializer ) end |
#serialize(event) ⇒ EventStoreClient::SerializedEvent
20 21 22 |
# File 'lib/event_store_client/mapper/default.rb', line 20 def serialize(event) Serializer::EventSerializer.call(event, serializer: serializer, config: config) end |