jsonapi_parameters 0.4.5 → 1.0.0
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/jsonapi_parameters/translator.rb +6 -6
- data/lib/jsonapi_parameters/version.rb +1 -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: daa7f46ec2ca9f23be7199bf5b8ee043a1b40317ed96070f9b0025a624328eeb
|
4
|
+
data.tar.gz: 29b227bd32c0b86cb6b5e29c368bc4728a445c369f22852037b3ff6f8e929b07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30da56dbc5654aed7331e5db54f54da59414fdf747a97c75755ba184af9e813a9ef50f7f2251f4af418ca04d11b54d353d1d4ca7c1e12a638e2049fa7bcae972
|
7
|
+
data.tar.gz: a67da822ec846764be2cc6a999a6a70655b7816b5be9b733770a2f4ec32246a39cf587260a2fdfe6fa6836fe0290cc0e08088b873a8649fb2e61ab1fab59d839
|
@@ -69,11 +69,11 @@ module JsonApi::Parameters
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def handle_to_many_relation(relationship_key, relationship_value)
|
72
|
-
with_inclusion =
|
72
|
+
with_inclusion = !relationship_value.empty?
|
73
73
|
|
74
|
-
vals = relationship_value.map do |
|
75
|
-
related_id =
|
76
|
-
related_type =
|
74
|
+
vals = relationship_value.map do |relationship|
|
75
|
+
related_id = relationship.dig(:id)
|
76
|
+
related_type = relationship.dig(:type)
|
77
77
|
|
78
78
|
included_object = find_included_object(
|
79
79
|
related_id: related_id, related_type: related_type
|
@@ -82,13 +82,13 @@ module JsonApi::Parameters
|
|
82
82
|
# If at least one related object has not been found in `included` tree,
|
83
83
|
# we should not attempt to "#{relationship_key}_attributes" but
|
84
84
|
# "#{relationship_key}_ids" instead.
|
85
|
-
with_inclusion
|
85
|
+
with_inclusion &= !included_object.empty?
|
86
86
|
|
87
87
|
if with_inclusion
|
88
88
|
included_object.delete(:type)
|
89
89
|
included_object[:attributes].merge(id: related_id)
|
90
90
|
else
|
91
|
-
|
91
|
+
relationship.dig(:id)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|