blob: 3b812ba30436e4d639a9b928dfb9b78cca237845 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# frozen_string_literal: true
module ActiveJob
module Serializers
# Provides methods to serialize and deserialize `ActiveSupport::HashWithIndifferentAccess`
# Values will be serialized by known serializers
class HashWithIndifferentAccessSerializer < HashSerializer # :nodoc:
def serialize(hash)
result = serialize_hash(hash)
result[key] = Serializers.serialize(true)
result
end
def deserialize(hash)
result = hash.transform_values { |v| Serializers.deserialize(v) }
result.delete(key)
result.with_indifferent_access
end
private
def key
WITH_INDIFFERENT_ACCESS_KEY
end
def klass
ActiveSupport::HashWithIndifferentAccess
end
end
end
end
|