jsonapi_compliable 0.11.6 → 0.11.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/Jsonapi/ResourceGenerator.html +1 -1
- data/docs/Jsonapi.html +1 -1
- data/docs/JsonapiCompliable/Adapters/Abstract.html +1 -1
- data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +1 -1
- data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +1 -1
- data/docs/JsonapiCompliable/Adapters/Null.html +1 -1
- data/docs/JsonapiCompliable/Adapters.html +1 -1
- data/docs/JsonapiCompliable/Base.html +1 -1
- data/docs/JsonapiCompliable/Configuration.html +100 -7
- data/docs/JsonapiCompliable/Deserializer.html +1 -1
- data/docs/JsonapiCompliable/Errors/BadFilter.html +1 -1
- data/docs/JsonapiCompliable/Errors/InvalidInclude.html +1 -1
- data/docs/JsonapiCompliable/Errors/RecordNotFound.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/Errors.html +1 -1
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +1 -1
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +1 -1
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +1 -1
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +1 -1
- data/docs/JsonapiCompliable/Extensions.html +1 -1
- data/docs/JsonapiCompliable/Query.html +1 -1
- data/docs/JsonapiCompliable/Rails.html +1 -1
- data/docs/JsonapiCompliable/Resource.html +1 -1
- data/docs/JsonapiCompliable/Scope.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/Scoping.html +1 -1
- data/docs/JsonapiCompliable/SerializableTempId.html +1 -1
- data/docs/JsonapiCompliable/Sideload.html +1 -1
- data/docs/JsonapiCompliable/Stats/DSL.html +1 -1
- data/docs/JsonapiCompliable/Stats/Payload.html +1 -1
- data/docs/JsonapiCompliable/Stats.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 +1 -1
- data/docs/JsonapiCompliable/Util/RelationshipPayload.html +1 -1
- data/docs/JsonapiCompliable/Util/RenderOptions.html +20 -4
- data/docs/JsonapiCompliable/Util/Sideload.html +1 -1
- data/docs/JsonapiCompliable/Util/ValidationResponse.html +1 -1
- data/docs/JsonapiCompliable/Util.html +1 -1
- data/docs/JsonapiCompliable.html +2 -2
- data/docs/_index.html +1 -1
- data/docs/file.README.html +1 -1
- data/docs/index.html +1 -1
- data/docs/method_list.html +266 -258
- data/docs/top-level-namespace.html +1 -1
- data/lib/jsonapi_compliable/configuration.rb +11 -0
- data/lib/jsonapi_compliable/scope.rb +22 -1
- data/lib/jsonapi_compliable/util/render_options.rb +1 -0
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +2 -2
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Mon May 7 09:24:11 2018 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>
|
@@ -4,11 +4,22 @@ module JsonapiCompliable
|
|
4
4
|
# @return [Boolean] Should we raise when the client requests a relationship not defined on the server?
|
5
5
|
# Defaults to true.
|
6
6
|
attr_accessor :raise_on_missing_sideload
|
7
|
+
# @return [Boolean] Concurrently fetch sideloads? This is *experimental* and may be removed.
|
8
|
+
# Defaults to false
|
9
|
+
attr_accessor :experimental_concurrency
|
7
10
|
|
8
11
|
# Set defaults
|
9
12
|
# @api private
|
10
13
|
def initialize
|
11
14
|
@raise_on_missing_sideload = true
|
15
|
+
@experimental_concurrency = false
|
16
|
+
end
|
17
|
+
|
18
|
+
# @api private
|
19
|
+
def experimental_concurrency=(val)
|
20
|
+
if val && !defined?(Concurrent::Promise)
|
21
|
+
raise "You must add the concurrent-ruby gem to opt-in to experimental concurrency"
|
22
|
+
end
|
12
23
|
end
|
13
24
|
end
|
14
25
|
end
|
@@ -81,6 +81,9 @@ module JsonapiCompliable
|
|
81
81
|
def sideload(results, includes)
|
82
82
|
return if results == []
|
83
83
|
|
84
|
+
concurrent = ::JsonapiCompliable.config.experimental_concurrency
|
85
|
+
promises = []
|
86
|
+
|
84
87
|
includes.each_pair do |name, nested|
|
85
88
|
sideload = @resource.sideload(name)
|
86
89
|
|
@@ -91,7 +94,25 @@ module JsonapiCompliable
|
|
91
94
|
end
|
92
95
|
else
|
93
96
|
namespace = Util::Sideload.namespace(@namespace, sideload.name)
|
94
|
-
sideload.resolve(results, @query, namespace)
|
97
|
+
resolve_sideload = -> { sideload.resolve(results, @query, namespace) }
|
98
|
+
if concurrent
|
99
|
+
promises << Concurrent::Promise.execute(&resolve_sideload)
|
100
|
+
else
|
101
|
+
resolve_sideload.call
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
if concurrent
|
107
|
+
# Wait for all promises to finish
|
108
|
+
while !promises.all? { |p| p.fulfilled? || p.rejected? }
|
109
|
+
sleep 0.01
|
110
|
+
end
|
111
|
+
# Re-raise the error with correct stacktrace
|
112
|
+
# OPTION** to avoid failing here?? if so need serializable patch
|
113
|
+
# to avoid loading data when association not loaded
|
114
|
+
if rejected = promises.find(&:rejected?)
|
115
|
+
raise rejected.reason
|
95
116
|
end
|
96
117
|
end
|
97
118
|
end
|
@@ -15,6 +15,7 @@ module JsonapiCompliable
|
|
15
15
|
fields = query_hash[:fields].dup
|
16
16
|
extra_fields = query_hash[:extra_fields]
|
17
17
|
|
18
|
+
# Ensure fields doesnt clobber extra fields
|
18
19
|
if extra_fields.any? && fields.any?
|
19
20
|
extra_fields.each { |k,v| fields[k] = fields[k].to_a + v }
|
20
21
|
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.11.
|
4
|
+
version: 0.11.7
|
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: 2018-05-
|
12
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|