class RubyEventStore::Protobuf::Mappers::Transformation::ProtobufNestedStructMetadata

Public Class Methods

new() click to toggle source
# File lib/ruby_event_store/protobuf/mappers/transformation/protobuf_nested_struct_metadata.rb, line 8
def initialize
  require_optional_dependency
end

Public Instance Methods

dump(record) click to toggle source
# File lib/ruby_event_store/protobuf/mappers/transformation/protobuf_nested_struct_metadata.rb, line 12
def dump(record)
  Record.new(
    event_id:   record.event_id,
    event_type: record.event_type,
    data:       record.data,
    metadata:   ProtobufNestedStruct::HashMapStringValue.dump(record.metadata),
    timestamp:  record.timestamp,
    valid_at:   record.valid_at,
  )
end
load(record) click to toggle source
# File lib/ruby_event_store/protobuf/mappers/transformation/protobuf_nested_struct_metadata.rb, line 23
def load(record)
  RubyEventStore::Mappers::Transformation::SymbolizeMetadataKeys.new.load(
    Record.new(
      event_id:   record.event_id,
      event_type: record.event_type,
      data:       record.data,
      metadata:   ProtobufNestedStruct::HashMapStringValue.load(record.metadata),
      timestamp:  record.timestamp,
      valid_at:   record.valid_at,
    )
  )
end
require_optional_dependency() click to toggle source
# File lib/ruby_event_store/protobuf/mappers/transformation/protobuf_nested_struct_metadata.rb, line 36
def require_optional_dependency
  require 'protobuf_nested_struct'
rescue LoadError
  raise LoadError, "cannot load such file -- protobuf_nested_struct. Add protobuf_nested_struct gem to Gemfile"
end