Skip to content

Commit

Permalink
EventClassRemapping superseded by upcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlyobvious committed Jan 9, 2021
1 parent 495b41b commit d666431
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 108 deletions.
1 change: 0 additions & 1 deletion ruby_event_store/lib/ruby_event_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
require 'ruby_event_store/mappers/in_memory_encryption_key_repository'
require 'ruby_event_store/mappers/transformation/domain_event'
require 'ruby_event_store/mappers/transformation/encryption'
require 'ruby_event_store/mappers/transformation/event_class_remapper'
require 'ruby_event_store/mappers/transformation/upcast'
require 'ruby_event_store/mappers/transformation/stringify_metadata_keys'
require 'ruby_event_store/mappers/transformation/symbolize_metadata_keys'
Expand Down
3 changes: 1 addition & 2 deletions ruby_event_store/lib/ruby_event_store/mappers/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
module RubyEventStore
module Mappers
class Default < PipelineMapper
def initialize(events_class_remapping: {})
def initialize
super(Pipeline.new(
Transformation::EventClassRemapper.new(events_class_remapping),
Transformation::SymbolizeMetadataKeys.new,
))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RubyEventStore
module Mappers
class JSONMapper < Default
def initialize(events_class_remapping: {})
def initialize
warn <<~EOW
Please replace RubyEventStore::Mappers::JSONMapper with RubyEventStore::Mappers::Default
Expand Down

This file was deleted.

14 changes: 0 additions & 14 deletions ruby_event_store/spec/mappers/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,6 @@ module Mappers
expect(event.metadata[:valid_at]).to eq(time)
end

specify '#record_to_event its using events class remapping' do
subject = described_class.new(events_class_remapping: {'EventNameBeforeRefactor' => 'SomethingHappened'})
record = Record.new(
event_id: domain_event.event_id,
data: { some_attribute: 5 },
metadata: { some_meta: 1 },
event_type: "EventNameBeforeRefactor",
timestamp: time,
valid_at: time,
)
event = subject.record_to_event(record)
expect(event).to eq(domain_event)
end

specify 'metadata keys are symbolized' do
record = Record.new(
event_id: domain_event.event_id,
Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions ruby_event_store/spec/projection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,29 +289,5 @@ module RubyEventStore

expect(state).to eq({})
end

specify "supports event class remapping" do
event_store = RubyEventStore::Client.new(
repository: repository,
mapper: Mappers::Default.new(events_class_remapping: { MoneyInvested.to_s => MoneyLost.to_s })
)
event_store.append(MoneyInvested.new(data: { amount: 1 }))

balance =
Projection
.from_all_streams
.init( -> { { total: 0 } })
.when(MoneyLost, ->(state, event) { state[:total] -= event.data[:amount] })
.run(event_store)
expect(balance).to eq(total: 0)

balance =
Projection
.from_all_streams
.init( -> { { total: 0 } })
.when([MoneyLost, MoneyInvested], ->(state, event) { state[:total] -= event.data[:amount] })
.run(event_store)
expect(balance).to eq(total: -1)
end
end
end

0 comments on commit d666431

Please sign in to comment.