Sha256: 7d32140a012e5eb6ce44a43ca66089b1a2b511b69d934bdb12529a1504e0e27b
Contents?: true
Size: 1015 Bytes
Versions: 9
Compression:
Stored size: 1015 Bytes
Contents
# frozen_string_literal: true module PgEventstore # @!visibility private class Preloader attr_reader :connection private :connection # @param connection [PgEventstore::Connection] def initialize(connection) @connection = connection end # @param raw_events [Array<Hash>] # @return [Array<Hash>] def preload_related_objects(raw_events) streams = stream_queries.find_by_ids(raw_events.map { _1['stream_id'] }).to_h { [_1['id'], _1] } types = event_type_queries.find_by_ids(raw_events.map { _1['event_type_id'] }).to_h { [_1['id'], _1] } raw_events.each do |event| event['stream'] = streams[event['stream_id']] event['type'] = types[event['event_type_id']]['type'] end end private # @return [PgEventstore::EventTypeQueries] def event_type_queries EventTypeQueries.new(connection) end # @return [PgEventstore::StreamQueries] def stream_queries StreamQueries.new(connection) end end end
Version data entries
9 entries across 9 versions & 1 rubygems