jsonapi_parameters 0.0.2 → 0.0.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 +5 -3
- data/lib/jsonapi_parameters/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e89f9f664c325116ba372099194a11107dad88d5c927c908a7c564610f0141f8
|
4
|
+
data.tar.gz: 453ac03e7af550862bb9c2d4850fb05bc4170dd0fd2eceaea28430c7b46d4ac2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9126a55807ecffcf62962e34ec6b041c2bef265a45fef3b37290aa713e0b12bc9fdab0fbe609de8142b43edaed9a25ea1c07aaa173c0ff8274ba1b58964cc18
|
7
|
+
data.tar.gz: 7272c3f6d165abe0b1eef16afadd8e8e4d02933f35d608b6aeba19c9cee67c452615f646d3c81200c1d8f8ae433a3fa466f4de6ec9f253534cd625857c426481
|
@@ -28,6 +28,8 @@ module JsonApi::Parameters
|
|
28
28
|
def jsonapi_main_body
|
29
29
|
jsonapi_unsafe_params.tap do |param|
|
30
30
|
jsonapi_relationships.each do |relationship_key, relationship_value|
|
31
|
+
relationship_value = relationship_value[:data]
|
32
|
+
|
31
33
|
key, val = case relationship_value
|
32
34
|
when Array
|
33
35
|
handle_to_many_relation(relationship_key, relationship_value)
|
@@ -57,8 +59,8 @@ module JsonApi::Parameters
|
|
57
59
|
key = "#{relationship_key.to_s.pluralize}_attributes".to_sym
|
58
60
|
|
59
61
|
val = relationship_value.map do |relationship_value|
|
60
|
-
related_id = relationship_value.dig(:
|
61
|
-
related_type = relationship_value.dig(:
|
62
|
+
related_id = relationship_value.dig(:id)
|
63
|
+
related_type = relationship_value.dig(:type)
|
62
64
|
|
63
65
|
included_object = find_included_object(
|
64
66
|
related_id: related_id, related_type: related_type
|
@@ -73,7 +75,7 @@ module JsonApi::Parameters
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def handle_to_one_relation(relationship_key, relationship_value)
|
76
|
-
related_id = relationship_value.dig(:
|
78
|
+
related_id = relationship_value.dig(:id)
|
77
79
|
related_type = relationship_key.to_s
|
78
80
|
|
79
81
|
included_object = find_included_object(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marahin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 1.9.1
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: hashdiff
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.3.8
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.3.8
|
167
181
|
description: JsonApi::Parameters allows you to easily translate JSON:API compliant
|
168
182
|
parameters to a structure expected by Rails.
|
169
183
|
email:
|