json_api_client 1.2.0 → 1.3.0
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/README.md +3 -3
- data/lib/json_api_client.rb +1 -0
- data/lib/json_api_client/connection.rb +1 -1
- data/lib/json_api_client/linking/top_level_links.rb +1 -0
- data/lib/json_api_client/query/builder.rb +1 -1
- data/lib/json_api_client/relationships/relations.rb +6 -2
- data/lib/json_api_client/resource.rb +3 -3
- data/lib/json_api_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26657a3496cb5b8c5d6ae5ed91657a709e3fe2eb
|
4
|
+
data.tar.gz: 07c8e931b94e2ce4c5ad99aded81c3261be6e586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43083388e55b1c38eade789c4bf2de4d71f9a1aa60490b82e2b57b1c03cf24384178fbbfa2caa48ef125537254b5baed608a6b9d42ab5dcef706b994cc65d901
|
7
|
+
data.tar.gz: 8fd7501b9abc8b4fd3b9de79a3c31d69cfd9ba6ae1a14181cc38b2ce12f04b435380dd556417b7a1d259c05cd22155fdedfd4a4f1afa8b0d83750df11ec2d837
|
data/README.md
CHANGED
@@ -221,13 +221,13 @@ article.created_at
|
|
221
221
|
|
222
222
|
```ruby
|
223
223
|
# makes request to /people?sort=age
|
224
|
-
youngest = Person.
|
224
|
+
youngest = Person.order(:age).all
|
225
225
|
|
226
226
|
# also makes request to /people?sort=age
|
227
|
-
youngest = Person.
|
227
|
+
youngest = Person.order(age: :asc).all
|
228
228
|
|
229
229
|
# makes request to /people?sort=-age
|
230
|
-
oldest = Person.
|
230
|
+
oldest = Person.order(age: :desc).all
|
231
231
|
```
|
232
232
|
|
233
233
|
## Paginating
|
data/lib/json_api_client.rb
CHANGED
@@ -5,7 +5,11 @@ module JsonApiClient
|
|
5
5
|
include Helpers::Dirty
|
6
6
|
include ActiveModel::Serialization
|
7
7
|
|
8
|
-
|
8
|
+
attr_reader :record_class
|
9
|
+
delegate :key_formatter, to: :record_class
|
10
|
+
|
11
|
+
def initialize(record_class, relations)
|
12
|
+
@record_class = record_class
|
9
13
|
self.attributes = relations
|
10
14
|
clear_changes_information
|
11
15
|
end
|
@@ -49,4 +53,4 @@ module JsonApiClient
|
|
49
53
|
|
50
54
|
end
|
51
55
|
end
|
52
|
-
end
|
56
|
+
end
|
@@ -292,7 +292,7 @@ module JsonApiClient
|
|
292
292
|
def initialize(params = {})
|
293
293
|
@persisted = nil
|
294
294
|
self.links = self.class.linker.new(params.delete("links") || {})
|
295
|
-
self.relationships = self.class.relationship_linker.new(params.delete("relationships") || {})
|
295
|
+
self.relationships = self.class.relationship_linker.new(self.class, params.delete("relationships") || {})
|
296
296
|
self.class.associations.each do |association|
|
297
297
|
if params.has_key?(association.attr_name.to_s)
|
298
298
|
set_attribute(association.attr_name, association.parse(params[association.attr_name.to_s]))
|
@@ -398,9 +398,9 @@ module JsonApiClient
|
|
398
398
|
if last_result_set.has_errors?
|
399
399
|
last_result_set.errors.each do |error|
|
400
400
|
if error.source_parameter
|
401
|
-
errors.add(error.source_parameter, error.title)
|
401
|
+
errors.add(error.source_parameter, error.title || error.detail)
|
402
402
|
else
|
403
|
-
errors.add(:base, error.title)
|
403
|
+
errors.add(:base, error.title || error.detail)
|
404
404
|
end
|
405
405
|
end
|
406
406
|
false
|
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.3.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: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|