File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,12 @@ def self.with_defaults
77 end
88
99 def self . with (
10- event_store : Rails . configuration . event_store ,
11- event_store_locator : nil ,
12- serializer : RubyEventStore ::Serializers ::YAML
10+ serializer : RubyEventStore ::Serializers ::YAML ,
11+ event_store_locator : -> { Rails . configuration . event_store }
1312 )
1413 Module . new do
1514 define_method :perform do |payload |
16- event_store = event_store_locator . call if event_store_locator
17- super ( event_store . deserialize ( serializer : serializer , **payload . transform_keys ( &:to_sym ) ) )
15+ super ( event_store_locator . call . deserialize ( serializer : serializer , **payload . transform_keys ( &:to_sym ) ) )
1816 end
1917 end
2018 end
Original file line number Diff line number Diff line change @@ -83,15 +83,14 @@ def perform(_event)
8383 end
8484
8585 specify "with specified event store" do
86- HandlerWithAnotherEventStore . prepend RailsEventStore ::AsyncHandler . with ( event_store : another_event_store )
86+ HandlerWithAnotherEventStore . prepend RailsEventStore ::AsyncHandler . with ( event_store_locator : -> { another_event_store } )
8787 event_store . subscribe_to_all_events ( HandlerWithAnotherEventStore )
8888 event_store . publish ( ev = RubyEventStore ::Event . new )
8989 expect ( $queue. pop ) . to eq ( ev )
9090 end
9191
9292 specify "with specified event store locator" do
9393 HandlerWithEventStoreLocator . prepend RailsEventStore ::AsyncHandler . with (
94- event_store : nil ,
9594 event_store_locator : -> { another_event_store }
9695 )
9796 another_event_store . subscribe_to_all_events ( HandlerWithEventStoreLocator )
@@ -101,7 +100,7 @@ def perform(_event)
101100
102101 specify "with specified serializer" do
103102 HandlerWithSpecifiedSerializer . prepend RailsEventStore ::AsyncHandler . with (
104- event_store : json_event_store ,
103+ event_store_locator : -> { json_event_store } ,
105104 serializer : JSON
106105 )
107106 json_event_store . subscribe_to_all_events ( HandlerWithSpecifiedSerializer )
You can’t perform that action at this time.
0 commit comments