json_api_client 1.12.0 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/json_api_client/included_data.rb +20 -10
- data/lib/json_api_client/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz: '
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e2ec83cd51f34ee34e32551913d01f9e9c9aa7d115ef475f75900aac7fceee2c
|
4
|
+
data.tar.gz: '0193065a70ff9f0b9f05f4c3205f702ebdc559e6fd3de48296a50d2c069261e1'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f72be97a49f8a922350f048147791696e333aa9e970d98a5640604843af3c5b6b500994db80ba47e9f968f51be80398585408c5802f984346531e455dbd8fb9
|
7
|
+
data.tar.gz: 04cbe2ac54b543c0fb22f3fdfc59cf838bcec1dbc5fb4f927399f308dba57f1a907a6992a1329e4d6bb72eaaaab8ae629714c497cab5d323e3425197ddb663f5
|
@@ -4,20 +4,30 @@ module JsonApiClient
|
|
4
4
|
|
5
5
|
def initialize(result_set, data)
|
6
6
|
record_class = result_set.record_class
|
7
|
-
|
8
|
-
|
7
|
+
grouped_data = data.group_by{|datum| datum["type"]}
|
8
|
+
grouped_included_set = grouped_data.each_with_object({}) do |(type, records), h|
|
9
9
|
klass = Utils.compute_type(record_class, record_class.key_formatter.unformat(type).singularize.classify)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
h[type] = records.map do |record|
|
11
|
+
params = klass.parser.parameters_from_resource(record)
|
12
|
+
klass.load(params).tap do |resource|
|
13
|
+
resource.last_result_set = result_set
|
14
|
+
end
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
if record_class.search_included_in_result_set
|
19
|
+
# deep_merge overrides the nested Arrays o_O
|
20
|
+
# {a: [1,2]}.deep_merge(a: [3,4]) # => {a: [3,4]}
|
21
|
+
grouped_included_set.merge!(result_set.group_by(&:type)) do |_, resources1, resources2|
|
22
|
+
resources1 + resources2
|
23
|
+
end
|
20
24
|
end
|
25
|
+
|
26
|
+
grouped_included_set.each do |type, resources|
|
27
|
+
grouped_included_set[type] = resources.index_by(&:id)
|
28
|
+
end
|
29
|
+
|
30
|
+
@data = grouped_included_set
|
21
31
|
end
|
22
32
|
|
23
33
|
def data_for(method_name, definition)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Ching
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -198,8 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
|
-
|
202
|
-
rubygems_version: 2.6.14.3
|
201
|
+
rubygems_version: 3.0.3
|
203
202
|
signing_key:
|
204
203
|
specification_version: 4
|
205
204
|
summary: Build client libraries compliant with specification defined by jsonapi.org
|