json_api_client 1.19.0 → 1.20.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
  SHA256:
3
- metadata.gz: 0e8f9fadfa22191ced6400cea007f0f62a05e8e6fbebc2af2fb5ac4180de5fe6
4
- data.tar.gz: 02eda05ecb80f46b09ce66773c997e00dbb1fa3bb72d340f596b9eb84cee22ff
3
+ metadata.gz: 399ea138115c4282afb7f24a8c6981533fc0e67d3e80078084002b8ab8cec5bd
4
+ data.tar.gz: aa737c7689874c8aef404b6aeabee2173b2294178486963928a2690495def95a
5
5
  SHA512:
6
- metadata.gz: 98abc203b52e5718f1d8b7ef1427536fd06d6ff257c4c01969a60a87d27eff2a471b46dabcd17917e877233fb810810758e6bcaa277b31708487cdacd322b358
7
- data.tar.gz: 1526cad7c4c92ebe245d74d7fdf09c803e078f4454be7f351ef5c5644fbc8d78e9a1aa356eecbcbbd0f0d1a310f0e502c0f9cd9100da838271a4fcbf9191d272
6
+ metadata.gz: 32657956fe3e7fc03e54d41c434a169613ee490684354cf1d59d864247743197de0858360a4d9e3f3003d073773563775bc8ca70a43be3948acb1c0557bd798c
7
+ data.tar.gz: 7aafe127cdc28013bf01e527c98b57f151004b49a5b9a482f12cd03ccce00b60e831c8aab80545651e4712ccb1a5f22bd04b157476503b01ab5ab20e4537750b
@@ -103,5 +103,16 @@ module JsonApiClient
103
103
  super nil, msg
104
104
  end
105
105
  end
106
+
107
+ class RecordNotSaved < ServerError
108
+ attr_reader :record
109
+
110
+ def initialize(message = nil, record = nil)
111
+ @record = record
112
+ end
113
+ def message
114
+ "Record not saved"
115
+ end
116
+ end
106
117
  end
107
118
  end
@@ -172,6 +172,12 @@ module JsonApiClient
172
172
  end
173
173
  end
174
174
 
175
+ def create!(attributes = {})
176
+ new(attributes).tap do |resource|
177
+ raise(Errors::RecordNotSaved.new("Failed to save the record", resource)) unless resource.save
178
+ end
179
+ end
180
+
175
181
  # Within the given block, add these headers to all requests made by
176
182
  # the resource class
177
183
  #
@@ -376,6 +382,11 @@ module JsonApiClient
376
382
  save
377
383
  end
378
384
 
385
+ def update_attributes!(attrs = {})
386
+ self.attributes = attrs
387
+ save ? true : raise(Errors::RecordNotSaved.new("Failed to update the record", self))
388
+ end
389
+
379
390
  # Alias to update_attributes
380
391
  #
381
392
  # @param attrs [Hash] Attributes to update
@@ -384,6 +395,10 @@ module JsonApiClient
384
395
  update_attributes(attrs)
385
396
  end
386
397
 
398
+ def update!(attrs = {})
399
+ update_attributes!(attrs)
400
+ end
401
+
387
402
  # Mark the record as persisted
388
403
  def mark_as_persisted!
389
404
  @persisted = true
@@ -1,3 +1,3 @@
1
1
  module JsonApiClient
2
- VERSION = "1.19.0"
2
+ VERSION = "1.20.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.19.0
4
+ version: 1.20.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: 2021-08-19 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport