jsonapi_compliable 0.11.15 → 0.11.16
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91b4575901e4872810f2439548136f4798893a9a
|
4
|
+
data.tar.gz: 206d39a17e6cd69449ef459447f33ef7db361c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 780451a9a115ea499c590ede80da6cde4dd680e22776ad4df06aca54e9e7bb119e8fd492ba0f21587cd9ac907cf9f4213019d225f3de9c051067f26efd6f49b3
|
7
|
+
data.tar.gz: a55448c5e88e2044e678b0b4fbdce36d79f79609a116f22a9cbb933e6781c5fefebc27727e28db2b5889808e7a822d0469608ef137a9ccf344263942d888ba60
|
@@ -53,7 +53,15 @@ module JsonapiCompliable
|
|
53
53
|
_scope.call.where(foreign_key => parent_ids.uniq.compact)
|
54
54
|
end
|
55
55
|
|
56
|
+
# The 'assigned' code here is to remove all children that do not
|
57
|
+
# get assigned. This is because there is no 'limit(1)' in the query.
|
58
|
+
# If we did 'limit(1)' for the query, it wouldn't work for index
|
59
|
+
# actions (only 1 would come back, when we want one *per result*).
|
60
|
+
#
|
61
|
+
# Instead, avoid pagination in the query, assign only one result, and
|
62
|
+
# remove anything else. This is more or less what AR does.
|
56
63
|
assign do |parents, children|
|
64
|
+
assigned = []
|
57
65
|
parents.each do |parent|
|
58
66
|
parent.association(association_name).loaded!
|
59
67
|
relevant_child = children.find { |c| c.send(foreign_key) == parent.send(primary_key) }
|
@@ -65,6 +73,10 @@ module JsonapiCompliable
|
|
65
73
|
association.send(:set_owner_attributes, relevant_child)
|
66
74
|
association.send(:set_inverse_instance, relevant_child)
|
67
75
|
association.send(:target=, relevant_child)
|
76
|
+
assigned << relevant_child
|
77
|
+
end
|
78
|
+
(children - assigned).each do |unassigned|
|
79
|
+
children.delete(unassigned)
|
68
80
|
end
|
69
81
|
end
|
70
82
|
|
@@ -399,8 +399,9 @@ module JsonapiCompliable
|
|
399
399
|
def resolve_basic(parents, query, namespace)
|
400
400
|
sideload_scope = scope_proc.call(parents)
|
401
401
|
sideload_scope = Scope.new(sideload_scope, resource_class.new, query, default_paginate: false, namespace: namespace)
|
402
|
-
|
403
|
-
|
402
|
+
sideload_scope.resolve do |sideload_results|
|
403
|
+
assign_proc.call(parents, sideload_results)
|
404
|
+
end
|
404
405
|
end
|
405
406
|
end
|
406
407
|
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.16
|
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-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|