Class: EsHttpClient::Event

Inherits:
Struct
  • Object
show all
Defined in:
lib/es_http_client/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



3
4
5
# File 'lib/es_http_client/event.rb', line 3

def data
  @data
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



3
4
5
# File 'lib/es_http_client/event.rb', line 3

def id
  @id
end

#numberObject

Returns the value of attribute number

Returns:

  • (Object)

    the current value of number



3
4
5
# File 'lib/es_http_client/event.rb', line 3

def number
  @number
end

#stream_idObject

Returns the value of attribute stream_id

Returns:

  • (Object)

    the current value of stream_id



3
4
5
# File 'lib/es_http_client/event.rb', line 3

def stream_id
  @stream_id
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



3
4
5
# File 'lib/es_http_client/event.rb', line 3

def type
  @type
end

#updatedObject

Returns the value of attribute updated

Returns:

  • (Object)

    the current value of updated



3
4
5
# File 'lib/es_http_client/event.rb', line 3

def updated
  @updated
end

#uriObject

Returns the value of attribute uri

Returns:

  • (Object)

    the current value of uri



3
4
5
# File 'lib/es_http_client/event.rb', line 3

def uri
  @uri
end

Class Method Details

.load_from(hash) ⇒ Object



5
6
7
8
9
10
# File 'lib/es_http_client/event.rb', line 5

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



12
13
14
# File 'lib/es_http_client/event.rb', line 12

def occurred_at
  data[:occurredAt]
end