Class: EsReadModel::Event

Inherits:
Struct
  • Object
show all
Defined in:
lib/es_readmodel/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



5
6
7
# File 'lib/es_readmodel/event.rb', line 5

def data
  @data
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



5
6
7
# File 'lib/es_readmodel/event.rb', line 5

def id
  @id
end

#numberObject

Returns the value of attribute number

Returns:

  • (Object)

    the current value of number



5
6
7
# File 'lib/es_readmodel/event.rb', line 5

def number
  @number
end

#stream_idObject

Returns the value of attribute stream_id

Returns:

  • (Object)

    the current value of stream_id



5
6
7
# File 'lib/es_readmodel/event.rb', line 5

def stream_id
  @stream_id
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



5
6
7
# File 'lib/es_readmodel/event.rb', line 5

def type
  @type
end

#updatedObject

Returns the value of attribute updated

Returns:

  • (Object)

    the current value of updated



5
6
7
# File 'lib/es_readmodel/event.rb', line 5

def updated
  @updated
end

#uriObject

Returns the value of attribute uri

Returns:

  • (Object)

    the current value of uri



5
6
7
# File 'lib/es_readmodel/event.rb', line 5

def uri
  @uri
end

Class Method Details

.load_from(hash) ⇒ Object



7
8
9
10
11
12
# File 'lib/es_readmodel/event.rb', line 7

def self.load_from(hash)
  return nil unless hash['data']
  data = JSON.parse(hash['data'], symbolize_names: true)
  event = Event.new(hash['eventId'], hash['eventType'], data, hash['updated'], hash['eventNumber'].to_i, hash['id'], hash['streamId'])
  event
end

Instance Method Details

#occurred_atObject



14
15
16
# File 'lib/es_readmodel/event.rb', line 14

def occurred_at
  data[:occurredAt]
end