Module: EventStore::HTTP::Controls::ReadStream::OutputSchema::Optimized::Transformer

Defined in:
lib/event_store/http/controls/read_stream/output_schema/optimized.rb

Defined Under Namespace

Modules: JSON

Class Method Summary collapse

Class Method Details

.instance(raw_data) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/event_store/http/controls/read_stream/output_schema/optimized.rb', line 33

def self.instance(raw_data)
  raw_data.fetch('entries').map do |entry|
    id = entry.fetch 'eventId'
    type = entry.fetch 'eventType'
    stream = entry.fetch 'streamId'
    position = entry.fetch 'eventNumber'
    global_position = entry.fetch 'positionEventNumber'

    data_text = entry.fetch 'data'
    data = EventStore::HTTP::JSON::Deserialize.(data_text)

     = entry['metaData']
     = nil if  == ''

    unless .nil?
       = EventStore::HTTP::JSON::Deserialize.()
    end

    Event::Example.new id, type, data, , stream, position, global_position
  end
end

.jsonObject



29
30
31
# File 'lib/event_store/http/controls/read_stream/output_schema/optimized.rb', line 29

def self.json
  JSON
end