jsonapi_compliable 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/rails_4.gemfile.lock +1 -1
- data/gemfiles/rails_5.gemfile.lock +1 -1
- data/lib/jsonapi_compliable/sideload.rb +11 -15
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 581276bd4edc803209be48bec1f03a72ffad2bd4
|
4
|
+
data.tar.gz: bda4a188aaecfab0a92b7f5bd70c45b5d7265420
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 341611451bd572895934709477ec7e974a47d7f5dd6decdb00a70b9ce724ed70b2a7ca0552f0be9e4a6afad91d94faff38c608f960ceb009587bd8a75c524e4e
|
7
|
+
data.tar.gz: 5870888b34b6caf62018c6ef69c7703c074126c6cf339ba49173cfe31b64eda2d930cf3bcd0da7906ec660949bfc091e8d0b924fcfe89ed4679af0268d5f18ea
|
@@ -75,36 +75,32 @@ module JsonapiCompliable
|
|
75
75
|
end
|
76
76
|
|
77
77
|
# Grab from nested sideloads, AND resource, recursively
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
def to_hash(levels_deep = 0)
|
84
|
-
levels_deep += 1
|
85
|
-
return {} if levels_deep == 10
|
86
|
-
|
87
|
-
{ name => {} }.tap do |hash|
|
78
|
+
def to_hash(processed = [])
|
79
|
+
return { name => {} } if processed.include?(self)
|
80
|
+
processed << self
|
81
|
+
|
82
|
+
result = { name => {} }.tap do |hash|
|
88
83
|
@sideloads.each_pair do |key, sideload|
|
89
|
-
hash[name][key] = sideload.to_hash(
|
84
|
+
hash[name][key] = sideload.to_hash(processed)[key] || {}
|
90
85
|
|
91
86
|
if sideload.polymorphic?
|
92
87
|
sideload.polymorphic_groups.each_pair do |type, sl|
|
93
|
-
hash[name][key].merge!(nested_sideload_hash(sl,
|
88
|
+
hash[name][key].merge!(nested_sideload_hash(sl, processed))
|
94
89
|
end
|
95
90
|
else
|
96
|
-
hash[name][key].merge!(nested_sideload_hash(sideload,
|
91
|
+
hash[name][key].merge!(nested_sideload_hash(sideload, processed))
|
97
92
|
end
|
98
93
|
end
|
99
94
|
end
|
95
|
+
result
|
100
96
|
end
|
101
97
|
|
102
98
|
private
|
103
99
|
|
104
|
-
def nested_sideload_hash(sideload,
|
100
|
+
def nested_sideload_hash(sideload, processed)
|
105
101
|
{}.tap do |hash|
|
106
102
|
if sideloading = sideload.resource_class.sideloading
|
107
|
-
hash.merge!(sideloading.to_hash(
|
103
|
+
hash.merge!(sideloading.to_hash(processed)[:base])
|
108
104
|
end
|
109
105
|
end
|
110
106
|
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.6.
|
4
|
+
version: 0.6.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-04-
|
12
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|