snfoil-rails 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sn_foil/jsonapi_deserializer.rb +4 -2
- data/lib/sn_foil/rails/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: a4aa9e8502480e615c440aca9f2bc70f507b94dc0a2e57a9c0b3d02cb2cb9d2d
|
4
|
+
data.tar.gz: d607d2fe7c5c1c8dd9ff69bace09247f3ec721fd5c1e4767592f6e7ad182dfb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25c8f8f25014f15a828795c95630e16714dd66f31bf50355819737b576a1248dcd0e592b33fd1b114b9a4fdbede8253f981b7246eade81d8654301c53949ff62
|
7
|
+
data.tar.gz: 99d2655356d0afea93703aa84768ebf90e91835e2d8eef689c6eafeca5bd659b02b37e9057f14785d806391fd69256936b768f497f7eabd7a68a40f246aa68ba
|
@@ -77,7 +77,7 @@ module SnFoil
|
|
77
77
|
def data_id(attributes, data)
|
78
78
|
if data[:id]
|
79
79
|
attributes[:id] = data[:id]
|
80
|
-
elsif
|
80
|
+
elsif data[:'local:id']
|
81
81
|
attributes[:lid] = data[:'local:id']
|
82
82
|
end
|
83
83
|
attributes
|
@@ -117,6 +117,7 @@ module SnFoil
|
|
117
117
|
resource_data = data.dig(:relationships, key, :data)
|
118
118
|
return attributes unless resource_data
|
119
119
|
|
120
|
+
resource_data = data_id(resource_data, resource_data)
|
120
121
|
attribute_data = lookup_relationship(resource_data)
|
121
122
|
relationship_data = { data: attribute_data || resource_data }
|
122
123
|
attributes[opts.fetch(:key) { key }] = deserializer.new(relationship_data, **options, included: included).parse
|
@@ -128,6 +129,7 @@ module SnFoil
|
|
128
129
|
return attributes unless array_data
|
129
130
|
|
130
131
|
attributes[opts.fetch(:key) { key }] = array_data.map do |resource_data|
|
132
|
+
resource_data = data_id(resource_data, resource_data)
|
131
133
|
attribute_data = lookup_relationship(resource_data)
|
132
134
|
relationship_data = { data: attribute_data || resource_data }
|
133
135
|
deserializer.new(relationship_data, **options, included: included).parse
|
@@ -136,7 +138,7 @@ module SnFoil
|
|
136
138
|
end
|
137
139
|
|
138
140
|
def lookup_relationship(type:, id: nil, lid: nil, **_opts)
|
139
|
-
raise ::ArgumentError,
|
141
|
+
raise ::ArgumentError, "missing keyword: id or lid for type: #{type}" unless id || lid
|
140
142
|
|
141
143
|
included&.find do |x|
|
142
144
|
x[:type].eql?(type) &&
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snfoil-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Howes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-03-
|
12
|
+
date: 2020-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|