Class: EventStoreClient::DeserializedEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/event_store_client/deserialized_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ DeserializedEvent

Returns a new instance of DeserializedEvent.

Parameters:

  • opts (Hash)

    a customizable set of options



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/event_store_client/deserialized_event.rb', line 20

def initialize(args = {})
  validate(args[:data]) unless args[:skip_validation]

  @data = args.fetch(:data) { {} }
  @metadata =
    args.fetch(:metadata) { {} }
        .merge(
          'type' => self.class.name,
          'content-type' => payload_content_type
        )

  @type = args[:type] || self.class.name
  @title = args[:title]
  @id = args[:id]
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/event_store_client/deserialized_event.rb', line 10

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/event_store_client/deserialized_event.rb', line 10

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



10
11
12
# File 'lib/event_store_client/deserialized_event.rb', line 10

def 
  @metadata
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/event_store_client/deserialized_event.rb', line 10

def title
  @title
end

#typeObject (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

#payload_content_typeObject

content type of the event data



40
41
42
43
44
# File 'lib/event_store_client/deserialized_event.rb', line 40

def payload_content_type
  return 'application/json' if EventStoreClient.config.adapter == :grpc

  'application/vnd.eventstore.events+json'
end

#schemaObject

event schema



37
# File 'lib/event_store_client/deserialized_event.rb', line 37

def schema; end