Skip to content

Commit c2cb3a8

Browse files
committed
Rephrased/improved bullets comparing custom mapper transformation vs upcast.
1 parent 040177b commit c2cb3a8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

posts/2025-09-12-evolving-event-names-and-payloads-in-rails-event-store-without-breaking-history.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,10 @@ upcast_map = {
287287
```
288288

289289
Custom Mapper Approach provides:
290-
- single transformation method handles all event types
291-
- clear separation of concerns
292-
- easier unit testing
293-
- better debugging with stack traces pointing to specific methods
290+
- single transformation method handles all event types - one `transform_payload` method with case statements vs multiple lambda functions
291+
- better code organization - separates event type mapping logic from payload transformation logic into distinct methods (`load` vs `transform_payload`)
292+
- easier unit testing - all transformation logic is contained within a single class, so unit tests can be written by passing records with different data and event_type combinations to the load method. With upcast, lambdas are scattered across the configuration map, making it harder to test individual transformations in isolation
293+
- better debugging experience - stack traces show meaningful method names like `RefundToReturnEventMapper#transform_payload` instead of generic `<lambda>` calls
294294

295295
On the other hand Transformation::Upcast shines for simpler use cases:
296296
- only event class names need changing, no payload transformation

0 commit comments

Comments
 (0)