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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2ba641517d1b4433f52881fcf610733d49eabff
4
- data.tar.gz: 55dd7a70e1da568c2263eb957764c4adc402f9e4
3
+ metadata.gz: 300aebe5d7b76910ab0d29fe3988f75bfc2cfef7
4
+ data.tar.gz: 28690fd4a57afdbc801e3e5c1c885700a1e9985c
5
5
  SHA512:
6
- metadata.gz: 21ab6475b3792bde16e04e63c40079408e8fac5dd1f1b3001c8b1412f1b85bae1c555ed3b022a9000df025952f008ddea305c2102248ef3ab2f1e30d83e298f4
7
- data.tar.gz: 8182598c1b91062d2a9bc2cca2c1cbfe5a8567995b28d3599dfa1433880f756466a75ce427c5f77a77055473f718da88bc6de5afe10e78741a1e14ac7089c3f9
6
+ metadata.gz: a0cc71c6451e2dfc01eb9422f3acfb78afc0fc57fee74b81604ab48b089671dab2952fbc103edeaf520eb1b1cfb6308c1225d40378b0a83c70fe565dcc7d56e0
7
+ data.tar.gz: ca7cdab114aeb8b24c2b58a4f3074caed3bbc7bfbc09fed0b10b5a9f4d11091a4eba4d4cbe9ab316d87be23ea5bc2be57b37e9f66d66a6318512e6b54e932f43
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/jsonapi-suite/jsonapi_compliable.svg?branch=master)](https://travis-ci.org/jsonapi-suite/jsonapi_compliable)
4
4
 
5
- [official documentation](https://jsonapi-suite.github.io/jsonapi_compliable)
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
- def to_hash
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
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  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.3
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-11 00:00:00.000000000 Z
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.5.1
195
+ rubygems_version: 2.6.7
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Easily build jsonapi.org-compatible APIs