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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8137c8564e802df86f6c11d282689e6105cb8bf5
4
- data.tar.gz: 510deb7ae79b300b65b50a02b068e51a3f4337a5
3
+ metadata.gz: 25562eb5beee62f18eacf4e9cbeced3d5a245b3f
4
+ data.tar.gz: f559d365a3647591fd0d221902303a3e84ff0e06
5
5
  SHA512:
6
- metadata.gz: 72d75538d796fa8fa9261eec3500cd96ffcd02fd58c5a5dc3b0567b4b4da3f9650f0973a9f06e36c73f0466901b5acc1c375c83bb3770cb7a6402a1b985dc401
7
- data.tar.gz: 8bd30b3f5c4d9d764ec41597bd7e3d6c78fa44732f5bbe549f4ea2e85f6de02a811c7403d47d505cb073221998f790224bbf70040ed80ded3ebf235bef1857ad
6
+ metadata.gz: efc0088447905a6120acfad7a4fb1d8790e49e3e7732f98b76c3063b3da64e18f4a49dbdb60dee8bb95b9833658ab5a99738e6a9ca2b4d4c1122b081d24602ea
7
+ data.tar.gz: f87a8b7b3dc56b0449afbfc67682ae901ab4ebe97db6c4cfdff1caad303a5b98128aca66ba60f1f2a1b3fe6459ff6477171ea3f545a4fcb6ea1cdc021a0472c7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jsonapi_compliable (0.6.0)
4
+ jsonapi_compliable (0.6.1)
5
5
  jsonapi-serializable (~> 0.1)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jsonapi_compliable (0.6.0)
4
+ jsonapi_compliable (0.6.1)
5
5
  jsonapi-serializable (~> 0.1)
6
6
 
7
7
  GEM
@@ -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 sideloading = sideload.resource_class.sideloading
91
- hash[name][key].merge!(sideloading.to_hash(levels_deep)[:base] || {})
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]
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
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.6.1
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-09 00:00:00.000000000 Z
12
+ date: 2017-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-serializable