jsonapi_compliable 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -0
  3. data/docs/Jsonapi/ResourceGenerator.html +1 -1
  4. data/docs/Jsonapi.html +1 -1
  5. data/docs/JsonapiCompliable/Adapters/Abstract.html +1 -1
  6. data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +1 -1
  7. data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +1 -1
  8. data/docs/JsonapiCompliable/Adapters/Null.html +1 -1
  9. data/docs/JsonapiCompliable/Adapters.html +1 -1
  10. data/docs/JsonapiCompliable/Base.html +1 -1
  11. data/docs/JsonapiCompliable/Deserializer.html +1 -1
  12. data/docs/JsonapiCompliable/Errors/BadFilter.html +1 -1
  13. data/docs/JsonapiCompliable/Errors/StatNotFound.html +1 -1
  14. data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +1 -1
  15. data/docs/JsonapiCompliable/Errors/ValidationError.html +1 -1
  16. data/docs/JsonapiCompliable/Errors.html +1 -1
  17. data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +1 -1
  18. data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +1 -1
  19. data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +1 -1
  20. data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +1 -1
  21. data/docs/JsonapiCompliable/Extensions.html +1 -1
  22. data/docs/JsonapiCompliable/Query.html +1 -1
  23. data/docs/JsonapiCompliable/Rails.html +1 -1
  24. data/docs/JsonapiCompliable/Resource.html +1 -1
  25. data/docs/JsonapiCompliable/Scope.html +1 -1
  26. data/docs/JsonapiCompliable/Scoping/Base.html +1 -1
  27. data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +1 -1
  28. data/docs/JsonapiCompliable/Scoping/ExtraFields.html +1 -1
  29. data/docs/JsonapiCompliable/Scoping/Filter.html +1 -1
  30. data/docs/JsonapiCompliable/Scoping/Filterable.html +1 -1
  31. data/docs/JsonapiCompliable/Scoping/Paginate.html +1 -1
  32. data/docs/JsonapiCompliable/Scoping/Sort.html +1 -1
  33. data/docs/JsonapiCompliable/Scoping.html +1 -1
  34. data/docs/JsonapiCompliable/SerializableTempId.html +1 -1
  35. data/docs/JsonapiCompliable/Sideload.html +29 -35
  36. data/docs/JsonapiCompliable/Stats/DSL.html +1 -1
  37. data/docs/JsonapiCompliable/Stats/Payload.html +1 -1
  38. data/docs/JsonapiCompliable/Stats.html +1 -1
  39. data/docs/JsonapiCompliable/Util/FieldParams.html +1 -1
  40. data/docs/JsonapiCompliable/Util/Hash.html +1 -1
  41. data/docs/JsonapiCompliable/Util/IncludeParams.html +1 -1
  42. data/docs/JsonapiCompliable/Util/Persistence.html +1 -1
  43. data/docs/JsonapiCompliable/Util/RelationshipPayload.html +1 -1
  44. data/docs/JsonapiCompliable/Util/RenderOptions.html +1 -1
  45. data/docs/JsonapiCompliable/Util/Sideload.html +244 -0
  46. data/docs/JsonapiCompliable/Util/ValidationResponse.html +1 -1
  47. data/docs/JsonapiCompliable/Util.html +3 -3
  48. data/docs/JsonapiCompliable.html +15 -15
  49. data/docs/_index.html +8 -1
  50. data/docs/class_list.html +1 -1
  51. data/docs/file.README.html +1 -1
  52. data/docs/index.html +1 -1
  53. data/docs/method_list.html +134 -126
  54. data/docs/top-level-namespace.html +1 -1
  55. data/lib/jsonapi_compliable/query.rb +2 -0
  56. data/lib/jsonapi_compliable/scope.rb +2 -1
  57. data/lib/jsonapi_compliable/sideload.rb +1 -3
  58. data/lib/jsonapi_compliable/util/sideload.rb +33 -0
  59. data/lib/jsonapi_compliable/version.rb +1 -1
  60. data/lib/jsonapi_compliable.rb +1 -0
  61. metadata +3 -1
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Tue Oct 3 09:22:25 2017 by
103
+ Generated on Tue Oct 3 14:55:06 2017 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.9 (ruby-2.3.0).
106
106
  </div>
@@ -173,9 +173,11 @@ module JsonapiCompliable
173
173
  end
174
174
 
175
175
  def parse_include(memo, incl_hash, namespace)
176
+ memo[namespace] ||= self.class.default_hash
176
177
  memo[namespace].merge!(include: incl_hash)
177
178
 
178
179
  incl_hash.each_pair do |key, sub_hash|
180
+ key = Util::Sideload.namespace(namespace, key)
179
181
  memo.merge!(parse_include(memo, sub_hash, key))
180
182
  end
181
183
 
@@ -81,7 +81,8 @@ module JsonapiCompliable
81
81
 
82
82
  includes.each_pair do |name, nested|
83
83
  sideload = @resource.sideload(name)
84
- sideload.resolve(results, @query)
84
+ namespace = Util::Sideload.namespace(@namespace, sideload.name)
85
+ sideload.resolve(results, @query, namespace)
85
86
  end
86
87
  end
87
88
 
@@ -264,9 +264,7 @@ module JsonapiCompliable
264
264
  # @see Resource#with_context
265
265
  # @return [void]
266
266
  # @api private
267
- def resolve(parents, query, namespace = nil)
268
- namespace ||= name
269
-
267
+ def resolve(parents, query, namespace)
270
268
  if polymorphic?
271
269
  resolve_polymorphic(parents, query)
272
270
  else
@@ -0,0 +1,33 @@
1
+ module JsonapiCompliable
2
+ module Util
3
+ # @api private
4
+ class Sideload
5
+ # Determine the namespace for the sideload
6
+ #
7
+ # In other words, given a query like
8
+ # /things?include=a.b
9
+ #
10
+ # When 'a' is sideloading 'b', b's namespace is 'b'.
11
+ #
12
+ # However, consider a recursive tree structure:
13
+ #
14
+ # /things?include=children.children
15
+ #
16
+ # The first occurrance of "children" will have the namespace
17
+ # "children", the second will be "children.children" and so forth.
18
+ #
19
+ # This is used to match up other criteria in the query:
20
+ #
21
+ # ?filter[children.children][a]=b
22
+ #
23
+ # @api private
24
+ def self.namespace(a, b)
25
+ if a.to_s.split('.')[0] == b.to_s
26
+ :"#{a}.#{b}"
27
+ else
28
+ b
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -22,6 +22,7 @@ require "jsonapi_compliable/util/hash"
22
22
  require "jsonapi_compliable/util/relationship_payload"
23
23
  require "jsonapi_compliable/util/persistence"
24
24
  require "jsonapi_compliable/util/validation_response"
25
+ require "jsonapi_compliable/util/sideload"
25
26
 
26
27
  # require correct jsonapi-rb before extensions
27
28
  if defined?(Rails)
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.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
@@ -183,6 +183,7 @@ files:
183
183
  - docs/JsonapiCompliable/Util/Persistence.html
184
184
  - docs/JsonapiCompliable/Util/RelationshipPayload.html
185
185
  - docs/JsonapiCompliable/Util/RenderOptions.html
186
+ - docs/JsonapiCompliable/Util/Sideload.html
186
187
  - docs/JsonapiCompliable/Util/ValidationResponse.html
187
188
  - docs/_index.html
188
189
  - docs/class_list.html
@@ -243,6 +244,7 @@ files:
243
244
  - lib/jsonapi_compliable/util/persistence.rb
244
245
  - lib/jsonapi_compliable/util/relationship_payload.rb
245
246
  - lib/jsonapi_compliable/util/render_options.rb
247
+ - lib/jsonapi_compliable/util/sideload.rb
246
248
  - lib/jsonapi_compliable/util/validation_response.rb
247
249
  - lib/jsonapi_compliable/version.rb
248
250
  homepage: