File tree 2 files changed +5
-8
lines changed
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
7
7
end
8
8
9
9
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 }
13
12
)
14
13
Module . new do
15
14
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 ) ) )
18
16
end
19
17
end
20
18
end
Original file line number Diff line number Diff line change @@ -83,15 +83,14 @@ def perform(_event)
83
83
end
84
84
85
85
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 } )
87
87
event_store . subscribe_to_all_events ( HandlerWithAnotherEventStore )
88
88
event_store . publish ( ev = RubyEventStore ::Event . new )
89
89
expect ( $queue. pop ) . to eq ( ev )
90
90
end
91
91
92
92
specify "with specified event store locator" do
93
93
HandlerWithEventStoreLocator . prepend RailsEventStore ::AsyncHandler . with (
94
- event_store : nil ,
95
94
event_store_locator : -> { another_event_store }
96
95
)
97
96
another_event_store . subscribe_to_all_events ( HandlerWithEventStoreLocator )
@@ -101,7 +100,7 @@ def perform(_event)
101
100
102
101
specify "with specified serializer" do
103
102
HandlerWithSpecifiedSerializer . prepend RailsEventStore ::AsyncHandler . with (
104
- event_store : json_event_store ,
103
+ event_store_locator : -> { json_event_store } ,
105
104
serializer : JSON
106
105
)
107
106
json_event_store . subscribe_to_all_events ( HandlerWithSpecifiedSerializer )
You can’t perform that action at this time.
0 commit comments