File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ module Marshalling
2020 # serialized with format_version = 6.1 using _dump, will always load using _load, ignoring wherever marshal_load is defined or not.
2121 # This ensures objects will always be deserialized with the method they were serialized with. We don´t need to worry about that.
2222
23- module ActiveRecordExtension
23+ class << self
24+ attr_reader :format_version
25+
2426 def format_version = ( version )
2527 case version
2628 when 6.1
@@ -30,7 +32,13 @@ def format_version=(version)
3032 else
3133 raise ArgumentError , "Unknown marshalling format: #{ version . inspect } "
3234 end
35+ @format_version = version
36+ end
37+ end
3338
39+ module ActiveRecordMarshallingExtension
40+ def format_version = ( version )
41+ ActiveType ::Marshalling . format_version = version
3442 super ( version )
3543 end
3644 end
@@ -49,4 +57,6 @@ def marshal_load(state)
4957 end
5058end
5159
52- ActiveRecord ::Marshalling . singleton_class . prepend ( ActiveType ::Marshalling ::ActiveRecordExtension )
60+ ActiveRecord ::Marshalling . singleton_class . prepend ( ActiveType ::Marshalling ::ActiveRecordMarshallingExtension )
61+ # Set ActiveType´s format_version to ActiveRecord´s, in case ActiveRecord uses the default value, which is set before we are loaded.
62+ ActiveType ::Marshalling . format_version = ActiveRecord ::Marshalling . format_version
You can’t perform that action at this time.
0 commit comments