lhs 21.1.4 → 21.2.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: e2612560f58416abc9a3ecd2583d5c53bf4ab14866735058e606a69e872c1263
4
- data.tar.gz: f423637d06798525364da4332b2edc502257e44d42713373077beec856890db8
3
+ metadata.gz: 6225eb173a7f2586b2a7bbeceb9a9d5c0a06c435708b9dd673a288e9e362745d
4
+ data.tar.gz: 75473dc1a4fd69c7ab8392c965e9ef932a19b30e1aae2505fa902b9e713540c9
5
5
  SHA512:
6
- metadata.gz: bb34fca037f6338abee76f32decb1188bdefc6a982b160ded012251bcf758796b4e47e69603933f3a0f057493ea62b85c4a14cd5acff65260a118bfebcdf8c5d
7
- data.tar.gz: 8a28967ed6a25915f2d02ebbd5b64ec6ceb4a403d675ef6846769773c2de06c0d7c99326dce06e2262ad01c38b5e69ddb827465cd3182d86efba5fc2fc10516e
6
+ metadata.gz: 897f78093924c54e3d8dce53655f075e8919c09d124cf71e676dd8b20dc3f429c623671f4697006c06d4babb07b8a18c65cd5e4c219cdc5a81955bd2d39b8fa4
7
+ data.tar.gz: 7f677d03fe47a75f3ac9e87ed9a4fc7f0cf51d30402b79b100fac79f3a6cdff8e85ef902d0615d35db84ea247a9207d08c9e96badd41ea4ff01bf504d9652e60
data/README.md CHANGED
@@ -1631,6 +1631,15 @@ POST https://service.example.com/records/1z-5r1fkaj { body: "{ 'name': 'Starbuck
1631
1631
 
1632
1632
  -> See [record validation](#record-validation) for how to handle validation errors when updating records.
1633
1633
 
1634
+ You can use `update` and the end of query-chains:
1635
+
1636
+ ```ruby
1637
+ # app/controllers/some_controller.rb
1638
+
1639
+ record.options(method: :put).update(recommended: true)
1640
+
1641
+ ```
1642
+
1634
1643
  You can also pass explicit request options to `update`, by passing two explicit hashes:
1635
1644
 
1636
1645
  ```ruby
@@ -1671,6 +1680,15 @@ POST https://service.example.com/records/1z-5r1fkaj { body: "{ 'name': 'Starbuck
1671
1680
 
1672
1681
  -> See [record validation](#record-validation) for how to handle validation errors when updating records.
1673
1682
 
1683
+ You can use `partial_update` at the end of query-chains:
1684
+
1685
+ ```ruby
1686
+ # app/controllers/some_controller.rb
1687
+
1688
+ record.options(method: :put).partial_update(recommended: true)
1689
+
1690
+ ```
1691
+
1674
1692
  You can also pass explicit request options to `partial_update`, by passing two explicit hashes:
1675
1693
 
1676
1694
  ```ruby
@@ -13,18 +13,15 @@ class LHS::Item < LHS::Proxy
13
13
  include EndpointLookup
14
14
  end
15
15
 
16
- def update(params, options = nil)
17
- update!(params, options)
16
+ def update(params, options = nil, partial_update = false)
17
+ update!(params, options, partial_update)
18
18
  rescue LHC::Error => e
19
19
  self.errors = LHS::Problems::Errors.new(e.response, record)
20
20
  false
21
21
  end
22
22
 
23
23
  def partial_update(params, options = nil)
24
- update!(params, options, true)
25
- rescue LHC::Error => e
26
- self.errors = LHS::Problems::Errors.new(e.response, record)
27
- false
24
+ update(params, options, true)
28
25
  end
29
26
 
30
27
  def partial_update!(params, options = nil)
@@ -198,6 +198,16 @@ class LHS::Record
198
198
  @record.update!(data, resolved_options.merge(options))
199
199
  end
200
200
 
201
+ def partial_update(data = {}, options = nil)
202
+ options ||= {}
203
+ @record.update(data, resolved_options.merge(options), true)
204
+ end
205
+
206
+ def partial_update!(data = {}, options = nil)
207
+ options ||= {}
208
+ @record.update!(data, resolved_options.merge(options), true)
209
+ end
210
+
201
211
  def valid?(options = nil)
202
212
  options ||= {}
203
213
  @record.valid?(resolved_options.merge(options))
data/lib/lhs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHS
4
- VERSION = '21.1.4'
4
+ VERSION = '21.2.0'
5
5
  end
@@ -151,4 +151,20 @@ describe LHS::Item do
151
151
  end
152
152
  end
153
153
  end
154
+
155
+ context 'chainable' do
156
+ it 'allows to chain partial_update with options' do
157
+ stub_request(:put, item.href)
158
+ .with(body: { name: 'Steve' }.to_json)
159
+ result = item.options(method: :put).partial_update(name: 'Steve')
160
+ expect(result).to eq true
161
+ end
162
+
163
+ it 'allows to chain partial_update! with options' do
164
+ stub_request(:put, item.href)
165
+ .with(body: { name: 'Steve' }.to_json)
166
+ result = item.options(method: :put).partial_update!(name: 'Steve')
167
+ expect(result).to eq true
168
+ end
169
+ end
154
170
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 21.1.4
4
+ version: 21.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors