jsonapi_parameters 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonapi_parameters/translator.rb +10 -1
- data/lib/jsonapi_parameters/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd088c3d78576a1a35f884af0a1ce64e8a9616c50038e6fac7ad64dee1cac3de
|
4
|
+
data.tar.gz: 8b1e5a6fe237922ababfd50c0d51e50c039a42c1fc0750af2972a631b73bf13e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15cd4a6231720e0bc2d34b83e531a5bec95610638e5f3af80815730c5e414b2b9a22ea12c64685cf30698eae6899ba35dbf241b718f58dfedda5603dc4b97cf5
|
7
|
+
data.tar.gz: 3a6b5ebfa7562b27a34779f8db849dcf3233b9739112b02d71384a05af178eb1dc7392456db2ea4fc808348a0b6f6e4f63a4329df002f305b899c4b1e0c6c8ec
|
@@ -35,12 +35,13 @@ module JsonApi::Parameters
|
|
35
35
|
jsonapi_unsafe_params.tap do |param|
|
36
36
|
jsonapi_relationships.each do |relationship_key, relationship_value|
|
37
37
|
relationship_value = relationship_value[:data]
|
38
|
-
|
39
38
|
key, val = case relationship_value
|
40
39
|
when Array
|
41
40
|
handle_to_many_relation(relationship_key, relationship_value)
|
42
41
|
when Hash
|
43
42
|
handle_to_one_relation(relationship_key, relationship_value)
|
43
|
+
when nil
|
44
|
+
handle_nil_relation(relationship_key)
|
44
45
|
else
|
45
46
|
raise jsonapi_not_implemented_err
|
46
47
|
end
|
@@ -114,6 +115,14 @@ module JsonApi::Parameters
|
|
114
115
|
["#{singularize(relationship_key)}_attributes".to_sym, included_object]
|
115
116
|
end
|
116
117
|
|
118
|
+
def handle_nil_relation(relationship_key)
|
119
|
+
# Graceful fail if nil on to-many association.
|
120
|
+
raise jsonapi_not_implemented_err if pluralize(relationship_key).to_sym == relationship_key
|
121
|
+
|
122
|
+
# Handle with empty hash.
|
123
|
+
handle_to_one_relation(relationship_key, {})
|
124
|
+
end
|
125
|
+
|
117
126
|
def find_included_object(related_id:, related_type:)
|
118
127
|
jsonapi_included.find do |included_object_enum|
|
119
128
|
included_object_enum[:id] &&
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Visuality
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|