Class: EventStoreClient::Serializer::EventSerializer
- Inherits:
-
Object
- Object
- EventStoreClient::Serializer::EventSerializer
- Defined in:
- lib/event_store_client/serializer/event_serializer.rb
Constant Summary collapse
- ALLOWED_EVENT_METADATA =
So far there are only these keys can be persisted in the metadata. You can pass whatever you want into a metadata hash, but all keys, except these - will be rejected. Define whitelisted keys and cut unwanted keys explicitly(later in this class).
%w[type content-type].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call(event) ⇒ EventStoreClient::SerializedEvent
-
#initialize(serializer:, config:) ⇒ EventSerializer
constructor
A new instance of EventSerializer.
Constructor Details
#initialize(serializer:, config:) ⇒ EventSerializer
Returns a new instance of EventSerializer.
26 27 28 29 |
# File 'lib/event_store_client/serializer/event_serializer.rb', line 26 def initialize(serializer:, config:) @serializer = serializer @config = config end |
Class Method Details
.call(event, config:, serializer: Serializer::Json) ⇒ EventStoreClient::SerializedEvent
16 17 18 |
# File 'lib/event_store_client/serializer/event_serializer.rb', line 16 def call(event, config:, serializer: Serializer::Json) new(serializer: serializer, config: config).call(event) end |
Instance Method Details
#call(event) ⇒ EventStoreClient::SerializedEvent
33 34 35 36 37 38 39 40 41 |
# File 'lib/event_store_client/serializer/event_serializer.rb', line 33 def call(event) SerializedEvent.new( id: event.id || SecureRandom.uuid, data: data(event), metadata: (event), custom_metadata: (event), serializer: serializer ) end |