json_api_client 1.2.0 → 1.3.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: 48365ff770cd7617bd8d4ca4bdc47815b1f16096
4
- data.tar.gz: 1691aa8373f863f00f9cf8020c810424aebd0fb2
3
+ metadata.gz: 26657a3496cb5b8c5d6ae5ed91657a709e3fe2eb
4
+ data.tar.gz: 07c8e931b94e2ce4c5ad99aded81c3261be6e586
5
5
  SHA512:
6
- metadata.gz: 72606bea939fb0c0770fd85120dcd7fa09762b44abcb8fcb53f95c2f0e60420b7c3acebfc55e3fec6e586585f7dad97df62a5bc6fab50961205f35085a7461c0
7
- data.tar.gz: f08837628c8717af1b6040f296d6609843b708d274da8d2197464445278eca13066f28d30a5e68da880b69080444f7b3f4be59b98dbf1f13ffb8a6f9081a9014
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.sort(:age).all
224
+ youngest = Person.order(:age).all
225
225
 
226
226
  # also makes request to /people?sort=age
227
- youngest = Person.sort(age: :asc).all
227
+ youngest = Person.order(age: :asc).all
228
228
 
229
229
  # makes request to /people?sort=-age
230
- oldest = Person.sort(age: :desc).all
230
+ oldest = Person.order(age: :desc).all
231
231
  ```
232
232
 
233
233
  ## Paginating
@@ -25,4 +25,5 @@ module JsonApiClient
25
25
  autoload :ResultSet, 'json_api_client/result_set'
26
26
  autoload :Schema, 'json_api_client/schema'
27
27
  autoload :Utils, 'json_api_client/utils'
28
+ autoload :VERSION, 'json_api_client/version'
28
29
  end
@@ -12,7 +12,7 @@ module JsonApiClient
12
12
  builder.use Middleware::JsonRequest
13
13
  builder.use Middleware::Status
14
14
  builder.use Middleware::ParseJson
15
- builder.adapter *adapter_options
15
+ builder.adapter(*adapter_options)
16
16
  end
17
17
  yield(self) if block_given?
18
18
  end
@@ -31,6 +31,7 @@ module JsonApiClient
31
31
  end
32
32
 
33
33
  def fetch_link(link_name)
34
+ return unless respond_to_missing?(link_name)
34
35
  record_class.requestor.linked(link_url_for(link_name))
35
36
  end
36
37
  end
@@ -2,7 +2,7 @@ module JsonApiClient
2
2
  module Query
3
3
  class Builder
4
4
 
5
- attr_reader :klass, :path_params
5
+ attr_reader :klass
6
6
  delegate :key_formatter, to: :klass
7
7
 
8
8
  def initialize(klass)
@@ -5,7 +5,11 @@ module JsonApiClient
5
5
  include Helpers::Dirty
6
6
  include ActiveModel::Serialization
7
7
 
8
- def initialize(relations)
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
@@ -1,3 +1,3 @@
1
1
  module JsonApiClient
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
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.2.0
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-07-28 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport