seri 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/serializer/version.rb +1 -1
- data/lib/serializer.rb +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46c74db605b3be850012902824a5e6eb8cea24840283a19c2a693b8494ab4c05
|
4
|
+
data.tar.gz: 1a5c0e021e369f0a8426a8e9295965a7c9c8e00da1b03058723c1846d9ae9a82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz: '
|
6
|
+
metadata.gz: 7b13a08781a36ed66bc7a2dc0407408a112e183c20177ef00a01509470c25e0e8bf164758e86405cd9be2828bcddd554fbfc1975f1390b774350bd1cb074e70c
|
7
|
+
data.tar.gz: '08ced2f63fcb804cba013f214284928f15a9f5ad4afbe7fd5002b4b08643908fc2bd8adcc64edf5a48831110ae313e51519cfad12a79fe589bad0e4db0d13580'
|
data/lib/serializer/version.rb
CHANGED
data/lib/serializer.rb
CHANGED
@@ -4,7 +4,11 @@ require 'serializer/group_serializer'
|
|
4
4
|
class Serializer
|
5
5
|
class SerializerError < StandardError; end
|
6
6
|
|
7
|
-
ARRAYS = %w(
|
7
|
+
ARRAYS = %w(
|
8
|
+
Array
|
9
|
+
ActiveRecord_AssociationRelation
|
10
|
+
ActiveRecord_Associations_CollectionProxy
|
11
|
+
)
|
8
12
|
|
9
13
|
Attribute = Struct.new(:key, :condition, :from, :serializer, :options)
|
10
14
|
|
@@ -64,7 +68,7 @@ class Serializer
|
|
64
68
|
def serialize_value(value, serializer)
|
65
69
|
return value unless serializer
|
66
70
|
|
67
|
-
if ARRAYS.any? { |match|
|
71
|
+
if ARRAYS.any? { |match| value.class.to_s.end_with?(match) }
|
68
72
|
value.map { |v| serializer.new(v).to_h }
|
69
73
|
else
|
70
74
|
serializer.new(value).to_h
|