jsonapi_compliable 0.6.1 → 0.6.2
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 +15 -2
- 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: 25562eb5beee62f18eacf4e9cbeced3d5a245b3f
|
4
|
+
data.tar.gz: f559d365a3647591fd0d221902303a3e84ff0e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efc0088447905a6120acfad7a4fb1d8790e49e3e7732f98b76c3063b3da64e18f4a49dbdb60dee8bb95b9833658ab5a99738e6a9ca2b4d4c1122b081d24602ea
|
7
|
+
data.tar.gz: f87a8b7b3dc56b0449afbfc67682ae901ab4ebe97db6c4cfdff1caad303a5b98128aca66ba60f1f2a1b3fe6459ff6477171ea3f545a4fcb6ea1cdc021a0472c7
|
@@ -3,6 +3,7 @@ module JsonapiCompliable
|
|
3
3
|
attr_reader :name,
|
4
4
|
:resource_class,
|
5
5
|
:polymorphic,
|
6
|
+
:polymorphic_groups,
|
6
7
|
:sideloads,
|
7
8
|
:scope_proc,
|
8
9
|
:assign_proc,
|
@@ -87,8 +88,12 @@ module JsonapiCompliable
|
|
87
88
|
@sideloads.each_pair do |key, sideload|
|
88
89
|
hash[name][key] = sideload.to_hash(levels_deep)[key] || {}
|
89
90
|
|
90
|
-
if
|
91
|
-
|
91
|
+
if sideload.polymorphic?
|
92
|
+
sideload.polymorphic_groups.each_pair do |type, sl|
|
93
|
+
hash[name][key].merge!(nested_sideload_hash(sl, levels_deep))
|
94
|
+
end
|
95
|
+
else
|
96
|
+
hash[name][key].merge!(nested_sideload_hash(sideload, levels_deep))
|
92
97
|
end
|
93
98
|
end
|
94
99
|
end
|
@@ -96,6 +101,14 @@ module JsonapiCompliable
|
|
96
101
|
|
97
102
|
private
|
98
103
|
|
104
|
+
def nested_sideload_hash(sideload, levels_deep)
|
105
|
+
{}.tap do |hash|
|
106
|
+
if sideloading = sideload.resource_class.sideloading
|
107
|
+
hash.merge!(sideloading.to_hash(levels_deep)[:base])
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
99
112
|
def resolve_polymorphic(parents, query)
|
100
113
|
parents.group_by(&@grouper).each_pair do |group_type, group_members|
|
101
114
|
sideload_for_group = @polymorphic_groups[group_type]
|
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.2
|
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-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|