Class: EventStoreClient::DeserializedEvent
- Inherits:
-
Object
- Object
- EventStoreClient::DeserializedEvent
- Defined in:
- lib/event_store_client/deserialized_event.rb
Constant Summary collapse
- InvalidDataError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(**args) ⇒ DeserializedEvent
constructor
A new instance of DeserializedEvent.
- #schema ⇒ Object
Constructor Details
#initialize(**args) ⇒ DeserializedEvent
Returns a new instance of DeserializedEvent.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/event_store_client/deserialized_event.rb', line 20 def initialize(**args) validation = schema.call(args[:data] || {}) raise InvalidDataError.new(message: validation.errors.to_h) if validation.errors.any? @data = args.fetch(:data) { {} } = args.fetch(:metadata) { {} }.merge( 'type' => self.class.name, 'content-type' => 'application/vnd.eventstore.events+json' ) @type = args[:type] || self.class.name @title = args[:title] @id = args[:id] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
12 13 14 |
# File 'lib/event_store_client/deserialized_event.rb', line 12 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/event_store_client/deserialized_event.rb', line 9 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/event_store_client/deserialized_event.rb', line 13 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/event_store_client/deserialized_event.rb', line 11 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/event_store_client/deserialized_event.rb', line 10 def type @type end |
Instance Method Details
#schema ⇒ Object
15 16 17 18 |
# File 'lib/event_store_client/deserialized_event.rb', line 15 def schema Dry::Schema.Params do end end |