@@ -46,8 +46,6 @@ def deserialize(arguments)
46
46
end
47
47
48
48
private
49
- # :nodoc:
50
- PERMITTED_TYPES = [ NilClass , String , Integer , Float , TrueClass , FalseClass ]
51
49
# :nodoc:
52
50
GLOBALID_KEY = "_aj_globalid"
53
51
# :nodoc:
@@ -67,13 +65,19 @@ def deserialize(arguments)
67
65
OBJECT_SERIALIZER_KEY , OBJECT_SERIALIZER_KEY . to_sym ,
68
66
WITH_INDIFFERENT_ACCESS_KEY , WITH_INDIFFERENT_ACCESS_KEY . to_sym ,
69
67
]
70
- private_constant :PERMITTED_TYPES , : RESERVED_KEYS, :GLOBALID_KEY ,
68
+ private_constant :RESERVED_KEYS , :GLOBALID_KEY ,
71
69
:SYMBOL_KEYS_KEY , :RUBY2_KEYWORDS_KEY , :WITH_INDIFFERENT_ACCESS_KEY
72
70
73
71
def serialize_argument ( argument )
74
72
case argument
75
- when * PERMITTED_TYPES
73
+ when nil , true , false , Integer , Float # Types that can hardly be subclassed
76
74
argument
75
+ when String
76
+ if argument . class == String
77
+ argument
78
+ else
79
+ Serializers . serialize ( argument )
80
+ end
77
81
when GlobalID ::Identification
78
82
convert_to_global_id_hash ( argument )
79
83
when Array
@@ -90,27 +94,27 @@ def serialize_argument(argument)
90
94
result = serialize_hash ( argument )
91
95
result [ aj_hash_key ] = symbol_keys
92
96
result
93
- when -> ( arg ) { arg . respond_to? ( :permitted? ) && arg . respond_to? ( :to_h ) }
94
- serialize_indifferent_hash ( argument . to_h )
95
97
else
96
- if BigDecimal === argument && !ActiveJob . use_big_decimal_serializer
98
+ if argument . respond_to? ( :permitted? ) && argument . respond_to? ( :to_h )
99
+ serialize_indifferent_hash ( argument . to_h )
100
+ elsif BigDecimal === argument && !ActiveJob . use_big_decimal_serializer
97
101
ActiveJob . deprecator . warn ( <<~MSG )
98
102
Primitive serialization of BigDecimal job arguments is deprecated as it may serialize via .to_s using certain queue adapters.
99
103
Enable config.active_job.use_big_decimal_serializer to use BigDecimalSerializer instead, which will be mandatory in Rails 7.2.
100
104
101
105
Note that if your application has multiple replicas, you should only enable this setting after successfully deploying your app to Rails 7.1 first.
102
106
This will ensure that during your deployment all replicas are capable of deserializing arguments serialized with BigDecimalSerializer.
103
107
MSG
104
- return argument
108
+ argument
109
+ else
110
+ Serializers . serialize ( argument )
105
111
end
106
-
107
- Serializers . serialize ( argument )
108
112
end
109
113
end
110
114
111
115
def deserialize_argument ( argument )
112
116
case argument
113
- when * PERMITTED_TYPES
117
+ when nil , true , false , String , Integer , Float
114
118
argument
115
119
when BigDecimal # BigDecimal may have been legacy serialized; Remove in 7.2
116
120
argument
0 commit comments