Class: RubyEventStore::Mappers::Transformation::EventClassRemapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/mappers/transformation/event_class_remapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(class_map) ⇒ EventClassRemapper

Returns a new instance of EventClassRemapper.



7
8
9
# File 'lib/ruby_event_store/mappers/transformation/event_class_remapper.rb', line 7

def initialize(class_map)
  @class_map = class_map
end

Instance Method Details

#dump(record) ⇒ Object



11
12
13
# File 'lib/ruby_event_store/mappers/transformation/event_class_remapper.rb', line 11

def dump(record)
  record
end

#load(record) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_event_store/mappers/transformation/event_class_remapper.rb', line 15

def load(record)
  Record.new(
    event_id: record.event_id,
    event_type: class_map[record.event_type] || record.event_type,
    data: record.data,
    metadata: record.,
    timestamp: record.timestamp,
    valid_at: record.valid_at
  )
end