fields-serializer 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fields/serializer/field_serializer.rb +9 -9
- data/lib/fields/serializer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e400a352bb3a82691a3a0e11f694611b7c0dd8e
|
4
|
+
data.tar.gz: 96a8af0bc2f59735656c6546525556c68cf74153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf045e0197b430a1c5795286801ae966b9fc5199189780d36bf3a03b555c91ae0a9268b1629db2db3a678e8a0c9651aa51bc44b582977bcaeaf1b80a265017ad
|
7
|
+
data.tar.gz: 0c0915f5f3e81d2516252b9ee29e351e0b0d18f9afaad8c88d698604c7ee112d95120c4293b0659ae0a2b0055841cbfe1e572387d2d391702a41ba2d0192ac6c
|
@@ -26,15 +26,15 @@ class FieldSerializer < ActiveModel::Serializer
|
|
26
26
|
|
27
27
|
def create_attribute_structure(attribute_stack, model)
|
28
28
|
return model unless model.present?
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
if model.kind_of?(ActiveRecord::Relation)
|
30
|
+
collection_attribute_structure(model, attribute_stack)
|
31
|
+
else
|
32
|
+
parent = attribute_stack.first
|
33
|
+
if attribute_stack.count > 1
|
34
|
+
attribute_structure(model, attribute_stack[1..-1], parent)
|
33
35
|
else
|
34
|
-
|
36
|
+
value_structure(model, parent)
|
35
37
|
end
|
36
|
-
else
|
37
|
-
value_structure(model, parent)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -42,8 +42,8 @@ class FieldSerializer < ActiveModel::Serializer
|
|
42
42
|
{ parent => create_attribute_structure(attribute_stack, model.send(parent)) }
|
43
43
|
end
|
44
44
|
|
45
|
-
def collection_attribute_structure(models, attribute_stack
|
46
|
-
models.map { |model|
|
45
|
+
def collection_attribute_structure(models, attribute_stack)
|
46
|
+
models.map { |model| create_attribute_structure(attribute_stack, model) }.compact
|
47
47
|
end
|
48
48
|
|
49
49
|
def merging_attributes(&block)
|