seri 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/serializer/version.rb +1 -1
- data/lib/serializer.rb +3 -1
- 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: fc67e1a87dd3afa34adf64fad07ed97552b65c9c25764c83345e304cf439a889
|
4
|
+
data.tar.gz: cc76131744bc905f3444969c1e02b7ce82917c881855d730c9ac0f5493bc329b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8fa1d5fe42fb81a3022cce31251816197e733f66bbf362d3cf2c7a0a1186da1cd53024846372f1d1039a4ba741773af6c3e038701beacc3bf76e57d0885ecb4
|
7
|
+
data.tar.gz: fc8707c87661070d53b7324b2a169337aa71fa024d1b362bd39de607885416b13ec6153109f7acba24f53ab6ad5851aa859c1f4d6ff0c7dca13c852f6f5af3f0
|
data/Gemfile.lock
CHANGED
data/lib/serializer/version.rb
CHANGED
data/lib/serializer.rb
CHANGED
@@ -4,6 +4,8 @@ require 'serializer/group_serializer'
|
|
4
4
|
class Serializer
|
5
5
|
class SerializerError < StandardError; end
|
6
6
|
|
7
|
+
ARRAYS = %w(Array ActiveRecord::AssociationRelation)
|
8
|
+
|
7
9
|
Attribute = Struct.new(:key, :condition, :from, :serializer, :options)
|
8
10
|
|
9
11
|
def self.attributes
|
@@ -62,7 +64,7 @@ class Serializer
|
|
62
64
|
def serialize_value(value, serializer)
|
63
65
|
return value unless serializer
|
64
66
|
|
65
|
-
if
|
67
|
+
if ARRAYS.include?(value.class.to_s)
|
66
68
|
value.map { |v| serializer.new(v).to_h }
|
67
69
|
else
|
68
70
|
serializer.new(value).to_h
|