jsonapi_compliable 0.5.3 → 0.5.4
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/README.md +1 -1
- data/lib/jsonapi_compliable/sideload.rb +11 -3
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 300aebe5d7b76910ab0d29fe3988f75bfc2cfef7
|
4
|
+
data.tar.gz: 28690fd4a57afdbc801e3e5c1c885700a1e9985c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0cc71c6451e2dfc01eb9422f3acfb78afc0fc57fee74b81604ab48b089671dab2952fbc103edeaf520eb1b1cfb6308c1225d40378b0a83c70fe565dcc7d56e0
|
7
|
+
data.tar.gz: ca7cdab114aeb8b24c2b58a4f3074caed3bbc7bfbc09fed0b10b5a9f4d11091a4eba4d4cbe9ab316d87be23ea5bc2be57b37e9f66d66a6318512e6b54e932f43
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/jsonapi-suite/jsonapi_compliable)
|
4
4
|
|
5
|
-
[official documentation](https://jsonapi-suite.github.io/
|
5
|
+
[official documentation](https://jsonapi-suite.github.io/jsonapi_suite)
|
6
6
|
|
7
7
|
Supported Rails versions: >= 4.1
|
8
8
|
|
@@ -60,13 +60,21 @@ module JsonapiCompliable
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# Grab from nested sideloads, AND resource, recursively
|
63
|
-
|
63
|
+
# To prevent circular relationships (author resource sideloads
|
64
|
+
# books and books resource sideloads authors), this allows
|
65
|
+
# sideloading up to 10 levels deep into the nesting of relationships
|
66
|
+
# We may want to make this configurable (possible at runtime), or
|
67
|
+
# maybe there is a better pattern here
|
68
|
+
def to_hash(levels_deep = 0)
|
69
|
+
levels_deep += 1
|
70
|
+
return {} if levels_deep == 10
|
71
|
+
|
64
72
|
{ name => {} }.tap do |hash|
|
65
73
|
@sideloads.each_pair do |key, sideload|
|
66
|
-
hash[name][key] = sideload.to_hash[key]
|
74
|
+
hash[name][key] = sideload.to_hash(levels_deep)[key] || {}
|
67
75
|
|
68
76
|
if sideloading = sideload.resource_class.sideloading
|
69
|
-
hash[name][key].merge!(sideloading.to_hash[:base])
|
77
|
+
hash[name][key].merge!(sideloading.to_hash(levels_deep)[:base] || {})
|
70
78
|
end
|
71
79
|
end
|
72
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi_compliable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-02-
|
12
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
194
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.
|
195
|
+
rubygems_version: 2.6.7
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: Easily build jsonapi.org-compatible APIs
|