Class: EventStoreClient::Serializer::EventDeserializer
- Inherits:
-
Object
- Object
- EventStoreClient::Serializer::EventDeserializer
- Defined in:
- lib/event_store_client/serializer/event_deserializer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(raw_event) ⇒ EventStoreClient::DeserializedEvent
-
#initialize(serializer:, config:) ⇒ EventDeserializer
constructor
A new instance of EventDeserializer.
Constructor Details
#initialize(serializer:, config:) ⇒ EventDeserializer
Returns a new instance of EventDeserializer.
23 24 25 26 |
# File 'lib/event_store_client/serializer/event_deserializer.rb', line 23 def initialize(serializer:, config:) @serializer = serializer @config = config end |
Class Method Details
.call(raw_event, config:, serializer: Serializer::Json) ⇒ EventStoreClient::DeserializedEvent
13 14 15 |
# File 'lib/event_store_client/serializer/event_deserializer.rb', line 13 def call(raw_event, config:, serializer: Serializer::Json) new(config: config, serializer: serializer).call(raw_event) end |
Instance Method Details
#call(raw_event) ⇒ EventStoreClient::DeserializedEvent
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/event_store_client/serializer/event_deserializer.rb', line 30 def call(raw_event) data = serializer.deserialize(normalize_serialized(raw_event.data)) = serializer.deserialize(normalize_serialized(raw_event.)) = raw_event..to_h event_class = EventStoreClient::EventClassResolver.new(config).resolve(['type']) event_class.new( skip_validation: true, id: raw_event.id.string, title: "#{raw_event.stream_revision}@#{raw_event.stream_identifier.stream_name}", type: ['type'], data: data, metadata: , custom_metadata: , stream_revision: raw_event.stream_revision, commit_position: raw_event.commit_position, prepare_position: raw_event.prepare_position, stream_name: raw_event.stream_identifier.stream_name ) end |