json_api_client 1.9.0 → 1.10.0
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: 8dc5a38f2bde33b9912837c82fa1fe5c9ef41c80
|
4
|
+
data.tar.gz: e8a926c76a1198ec9cf720fae46335e12f2c54fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d346d1b746c28b381e77a5842403808377f924feacce7d57f5f8d7ce9df4e9ccff8312a39e2313c0babc31965860e0af3c1b66648df60923af35cd2148467ad
|
7
|
+
data.tar.gz: 1951d5ea9ff1879cebd7f1c1fbafd25f752e2adbbdfd2f636231b23e4d16e8c282def341a5a368f282f64308c596388dc1a2eb58676bec90f3677254100aa006
|
@@ -21,6 +21,13 @@ module JsonApiClient
|
|
21
21
|
def from_result_set(result_set)
|
22
22
|
result_set.to_a
|
23
23
|
end
|
24
|
+
|
25
|
+
def load_records(data)
|
26
|
+
data.map do |d|
|
27
|
+
record_class = Utils.compute_type(klass, d["type"].classify)
|
28
|
+
record_class.load id: d["id"]
|
29
|
+
end
|
30
|
+
end
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
@@ -537,7 +537,11 @@ module JsonApiClient
|
|
537
537
|
def relationship_data_for(name, relationship_definition)
|
538
538
|
# look in included data
|
539
539
|
if relationship_definition.key?("data")
|
540
|
-
|
540
|
+
if relationships.attribute_changed?(name)
|
541
|
+
return relation_objects_for(name, relationship_definition)
|
542
|
+
else
|
543
|
+
return included_data_for(name, relationship_definition)
|
544
|
+
end
|
541
545
|
end
|
542
546
|
|
543
547
|
url = relationship_definition["links"]["related"]
|
@@ -548,6 +552,13 @@ module JsonApiClient
|
|
548
552
|
nil
|
549
553
|
end
|
550
554
|
|
555
|
+
def relation_objects_for(name, relationship_definition)
|
556
|
+
data = relationship_definition["data"]
|
557
|
+
assoc = association_for(name)
|
558
|
+
return if data.nil? || assoc.nil?
|
559
|
+
assoc.load_records(data)
|
560
|
+
end
|
561
|
+
|
551
562
|
def method_missing(method, *args)
|
552
563
|
relationship_definition = relationship_definition_for(method)
|
553
564
|
|
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.
|
4
|
+
version: 1.10.0
|
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-
|
11
|
+
date: 2019-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|