arkency/rails_event_store

View on GitHub
ruby_event_store/lib/ruby_event_store/mappers/transformation/stringify_metadata_keys.rb

Summary

Maintainability
A
40 mins
Test Coverage
# frozen_string_literal: true

module RubyEventStore
  module Mappers
    module Transformation
      class StringifyMetadataKeys
        def dump(record)
          stringify(record)
        end

        def load(record)
          stringify(record)
        end

        private

        def stringify(record)
          Record.new(
            event_id: record.event_id,
            event_type: record.event_type,
            data: record.data,
            metadata: TransformKeys.stringify(record.metadata),
            timestamp: record.timestamp,
            valid_at: record.valid_at
          )
        end
      end
    end
  end
end