jsonapi_compliable 0.9.0 → 0.9.1
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 +4 -4
- data/.travis.yml +8 -0
- data/docs/Jsonapi.html +1 -1
- data/docs/Jsonapi/ResourceGenerator.html +13 -123
- data/docs/JsonapiCompliable.html +2 -2
- data/docs/JsonapiCompliable/Adapters.html +1 -1
- data/docs/JsonapiCompliable/Adapters/Abstract.html +193 -17
- data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +106 -20
- data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +4 -4
- data/docs/JsonapiCompliable/Adapters/Null.html +2 -2
- data/docs/JsonapiCompliable/Base.html +2 -2
- data/docs/JsonapiCompliable/Deserializer.html +25 -23
- data/docs/JsonapiCompliable/Errors.html +1 -1
- data/docs/JsonapiCompliable/Errors/BadFilter.html +1 -1
- data/docs/JsonapiCompliable/Errors/StatNotFound.html +1 -1
- data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +1 -1
- data/docs/JsonapiCompliable/Errors/ValidationError.html +1 -1
- data/docs/JsonapiCompliable/Extensions.html +1 -1
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +1 -1
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +1 -1
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +1 -1
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +1 -1
- data/docs/JsonapiCompliable/Query.html +1 -1
- data/docs/JsonapiCompliable/Rails.html +1 -1
- data/docs/JsonapiCompliable/Resource.html +261 -109
- data/docs/JsonapiCompliable/Scope.html +1 -1
- data/docs/JsonapiCompliable/Scoping.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Base.html +1 -1
- data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +1 -1
- data/docs/JsonapiCompliable/Scoping/ExtraFields.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Filter.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Filterable.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Paginate.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Sort.html +1 -1
- data/docs/JsonapiCompliable/SerializableTempId.html +1 -1
- data/docs/JsonapiCompliable/Sideload.html +691 -124
- data/docs/JsonapiCompliable/Stats.html +1 -1
- data/docs/JsonapiCompliable/Stats/DSL.html +1 -1
- data/docs/JsonapiCompliable/Stats/Payload.html +1 -1
- data/docs/JsonapiCompliable/Util.html +1 -1
- data/docs/JsonapiCompliable/Util/FieldParams.html +1 -1
- data/docs/JsonapiCompliable/Util/Hash.html +1 -1
- data/docs/JsonapiCompliable/Util/IncludeParams.html +1 -1
- data/docs/JsonapiCompliable/Util/Persistence.html +22 -12
- data/docs/JsonapiCompliable/Util/RelationshipPayload.html +1 -1
- data/docs/JsonapiCompliable/Util/RenderOptions.html +1 -1
- data/docs/JsonapiCompliable/Util/ValidationResponse.html +1 -1
- data/docs/_index.html +1 -1
- data/docs/file.README.html +11 -14
- data/docs/index.html +11 -14
- data/docs/method_list.html +368 -280
- data/docs/top-level-namespace.html +1 -1
- data/lib/jsonapi_compliable/sideload.rb +38 -17
- data/lib/jsonapi_compliable/util/relationship_payload.rb +1 -0
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +3 -3
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Thu Sep 28 17:28:09 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>
|
@@ -43,6 +43,21 @@ module JsonapiCompliable
|
|
43
43
|
extend @resource_class.config[:adapter].sideloading_module
|
44
44
|
end
|
45
45
|
|
46
|
+
# @api private
|
47
|
+
def self.max_depth
|
48
|
+
@max_depth || 2
|
49
|
+
end
|
50
|
+
|
51
|
+
# Set maximum levels of sideload recursion
|
52
|
+
# /authors?comments.authors would be one level
|
53
|
+
# /authors?comments.authors.comments.authors would be two levels
|
54
|
+
# etc
|
55
|
+
#
|
56
|
+
# Default max depth is 2
|
57
|
+
def self.max_depth=(val)
|
58
|
+
@max_depth = val
|
59
|
+
end
|
60
|
+
|
46
61
|
# @see #resource_class
|
47
62
|
# @return [Resource] an instance of +#resource_class+
|
48
63
|
def resource
|
@@ -331,6 +346,19 @@ module JsonapiCompliable
|
|
331
346
|
@sideloads[name]
|
332
347
|
end
|
333
348
|
|
349
|
+
# @api private
|
350
|
+
def all_sideloads
|
351
|
+
{}.tap do |all|
|
352
|
+
if polymorphic?
|
353
|
+
polymorphic_groups.each_pair do |type, sl|
|
354
|
+
all.merge!(sl.resource.sideloading.all_sideloads)
|
355
|
+
end
|
356
|
+
else
|
357
|
+
all.merge!(@sideloads.merge(resource.sideloading.sideloads))
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
334
362
|
# Looks at all nested sideload, and all nested sideloads for the
|
335
363
|
# corresponding Resources, and returns an Include Directive hash
|
336
364
|
#
|
@@ -354,27 +382,20 @@ module JsonapiCompliable
|
|
354
382
|
#
|
355
383
|
# @return [Hash] The nested include hash
|
356
384
|
# @api private
|
357
|
-
def to_hash(
|
358
|
-
|
359
|
-
|
360
|
-
return { name => {} }
|
361
|
-
end
|
362
|
-
processed << self
|
385
|
+
def to_hash(depth_chain = [], parent = nil)
|
386
|
+
depth = depth_chain.select { |arr| arr == [parent, self] }.length
|
387
|
+
return {} if depth >= self.class.max_depth
|
363
388
|
|
364
|
-
|
365
|
-
|
366
|
-
|
389
|
+
unless (parent && parent.name == :base) || name == :base
|
390
|
+
depth_chain += [[parent, self]]
|
391
|
+
end
|
367
392
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
else
|
373
|
-
hash[name][key].merge!(nested_sideload_hash(sideload, processed))
|
374
|
-
end
|
393
|
+
{ name => {} }.tap do |hash|
|
394
|
+
all_sideloads.each_pair do |key, sl|
|
395
|
+
sideload_hash = sl.to_hash(depth_chain, self)
|
396
|
+
hash[name].merge!(sideload_hash)
|
375
397
|
end
|
376
398
|
end
|
377
|
-
result
|
378
399
|
end
|
379
400
|
|
380
401
|
# @api private
|
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.9.
|
4
|
+
version: 0.9.1
|
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-09-
|
12
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
265
|
version: '0'
|
266
266
|
requirements: []
|
267
267
|
rubyforge_project:
|
268
|
-
rubygems_version: 2.6.
|
268
|
+
rubygems_version: 2.6.13
|
269
269
|
signing_key:
|
270
270
|
specification_version: 4
|
271
271
|
summary: Easily build jsonapi.org-compatible APIs
|