Sha256: 2fe5c164317da0e3d27aa3533c00699f7f925abdf63f70d0ad45eee3af61ae59

Contents?: true

Size: 574 Bytes

Versions: 4

Compression:

Stored size: 574 Bytes

Contents

module EsHttpClient

  class Event < Struct.new(:id, :type, :data, :updated, :number, :uri, :stream_id)

    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

    def occurred_at
      data[:occurredAt]
    end

    private

    def initialize(id, type, data, updated=nil, number=nil, uri=nil, stream_id=nil)
      super
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
es-http-client-0.2.0 lib/es_http_client/event.rb
es-http-client-0.1.2 lib/es_http_client/event.rb
es-http-client-0.1.1 lib/es_http_client/event.rb
es-http-client-0.1.0 lib/es_http_client/event.rb