activejsonmodel 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc97da5d920f8d4bd3086c08d7e785867d6aad6d76549ac5d4642d0dc7905269
|
4
|
+
data.tar.gz: be4f3c6d7b7eadee052cc42d7e7b7e3c4df3f7d86d9d673c6ae0c6dcd34f09f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ffe713e2616fff952482e90adab32f709634e6976040f7dd0c43fa34c5db81de5cf0f8f3829f83cfd9d54730618411d9b8003cfe1e415cf51111dc529a990cd
|
7
|
+
data.tar.gz: f28fee77d5d862f8615b146e7526d6593393518988f7ced44f1871914350e429dc0b1c44763674a1c1946f29699efa1bf3b1c114b87891a5133f1ac098a6352c
|
@@ -48,14 +48,13 @@ if Gem.find_files("symmetric-encryption").any? &&
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def serialize(value)
|
51
|
-
|
52
|
-
when @clazz
|
51
|
+
if value.respond_to?(:dump_to_json)
|
53
52
|
SymmetricEncryption.encrypt(
|
54
|
-
|
53
|
+
value.dump_to_json,
|
55
54
|
random_iv: true,
|
56
55
|
type: :json
|
57
56
|
)
|
58
|
-
|
57
|
+
elsif ::Hash === value || ::HashWithIndifferentAccess === value || ::Array === value
|
59
58
|
SymmetricEncryption.encrypt(
|
60
59
|
value,
|
61
60
|
random_iv: true,
|
@@ -63,10 +63,9 @@ if Gem.find_files("active_record").any?
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def serialize(value)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
when ::Hash, ::HashWithIndifferentAccess, ::Array
|
66
|
+
if value.respond_to?(:dump_to_json)
|
67
|
+
::ActiveSupport::JSON.encode(value.dump_to_json)
|
68
|
+
elsif ::Hash === value || ::HashWithIndifferentAccess === value || ::Array === value
|
70
69
|
::ActiveSupport::JSON.encode(value)
|
71
70
|
else
|
72
71
|
super
|
@@ -564,7 +564,10 @@ module ActiveJsonModel
|
|
564
564
|
#
|
565
565
|
# @param val either an instance of this model or a Hash like object
|
566
566
|
def active_json_model_cast(val)
|
567
|
-
|
567
|
+
# For polymorphic objects, it's possible that there won't be
|
568
|
+
# a base-class relationship, so just assume that if the
|
569
|
+
# object is an ActiveJsonModel object, it's good.
|
570
|
+
if val.respond_to?(:dump_to_json)
|
568
571
|
val
|
569
572
|
elsif val.is_a?(::Hash) || val.is_a?(::HashWithIndifferentAccess)
|
570
573
|
self.load(val)
|