Sha256: 8d169f42cecb228ecae7fde95634e1860cc7f598ea51eb92cdd2173ed48a62d5

Contents?: true

Size: 590 Bytes

Versions: 12

Compression:

Stored size: 590 Bytes

Contents

require 'json'

module EsReadModel

  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

12 entries across 12 versions & 1 rubygems

Version Path
es-readmodel-1.0.2 lib/es_readmodel/event.rb
es-readmodel-1.0.1 lib/es_readmodel/event.rb
es-readmodel-1.0.0 lib/es_readmodel/event.rb
es-readmodel-0.1.0 lib/es_readmodel/event.rb
es-readmodel-0.0.10 lib/es_readmodel/event.rb
es-readmodel-0.0.9 lib/es_readmodel/event.rb
es-readmodel-0.0.8 lib/es_readmodel/event.rb
es-readmodel-0.0.7 lib/es_readmodel/event.rb
es-readmodel-0.0.6 lib/es_readmodel/event.rb
es-readmodel-0.0.5 lib/es_readmodel/event.rb
es-readmodel-0.0.4 lib/es_readmodel/event.rb
es-readmodel-0.0.1 lib/es_readmodel/event.rb