class RubyEventStore::Mappers::Transformation::Upcast::RecordUpcaster

Public Class Methods

new(upcast_map) click to toggle source
# File lib/ruby_event_store/mappers/transformation/upcast.rb, line 8
def initialize(upcast_map)
  @upcast_map = upcast_map
end

Public Instance Methods

call(record) click to toggle source
# File lib/ruby_event_store/mappers/transformation/upcast.rb, line 12
def call(record)
  identity = lambda { |r| r }
  new_record = @upcast_map.fetch(record.event_type, identity)[record]
  new_record.equal?(record) ? record : call(new_record)
end