Skip to content

Commit 402d876

Browse files
committed
Refactor
1 parent cefd3d5 commit 402d876

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ruby_event_store-active_record/lib/ruby_event_store/active_record/event_repository.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ def initialize(model_factory: WithDefaultModels.new, serializer:)
3232
@event_klass.include(SkipJsonSerialization)
3333
end
3434
@repo_reader = EventRepositoryReader.new(@event_klass, @stream_klass, serializer)
35-
EventRepositoryReader.prepend(DoubleSerializationDetector) if serializer == JSON && json_data_type?
35+
rescue_from_double_json_serialization!
3636

3737
@index_violation_detector = IndexViolationDetector.new(@event_klass.table_name, @stream_klass.table_name)
3838
end
3939

40+
def rescue_from_double_json_serialization!
41+
EventRepositoryReader.prepend(DoubleSerializationDetector) if serializer == JSON && json_data_type?
42+
end
43+
4044
def append_to_stream(records, stream, expected_version)
4145
return if records.empty?
4246

0 commit comments

Comments
 (0)