lhs 13.1.0 → 13.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
  SHA1:
3
- metadata.gz: 619fa442b169b251cb6501e59940d0c587010de6
4
- data.tar.gz: e0fdac02b30115bab5c2e98eb8e1f0847d042921
3
+ metadata.gz: d47809d2cae46a30a0e8e5fb00efc3f739b81d42
4
+ data.tar.gz: 8c8aa4ec034214fc41b036de60adefcdb5b50d8b
5
5
  SHA512:
6
- metadata.gz: ab7fcafa5689e4796f82a7c2da65600c60068dbb2325763775f8d5db833d1814730d91b1819e97f7e29aa51001cc5225e983b2fb58a52ae106fcc269a3f27dd7
7
- data.tar.gz: 6f73e3433aa5e955c336da8b2dddc8aebd9b557b8256efd2bf4adc6503376fb75951055d0cddc759f8b3f6efa4509a64c280bf052be8791d0cad00edb4b3bda6
6
+ metadata.gz: e5d28cf68e8ee0a2946d2bfe9e21381e7e2c8616484eb09877725af9f066483b4554fd55fcdb467a273210fc208dc2638973a56a3810fa7d7ca1176ed6298c94
7
+ data.tar.gz: 50c2a89618fef4370369b85a18aa485de740d17f270954786d8adf83b9044ca7f9ead3ace0262cf0d4612da5b6f3406ed04df7e7de372ad3bddb8cfdd8fefc6c
data/README.md CHANGED
@@ -183,7 +183,7 @@ record = Record.where(color: 'blue')
183
183
 
184
184
  If an error handler returns `nil` an empty LHS::Record is returned, not `nil`!
185
185
 
186
- In case you want to ignore errores and continue working with `nil` in those cases,
186
+ In case you want to ignore errors and continue working with `nil` in those cases,
187
187
  please use `ignore`:
188
188
 
189
189
  ```ruby
@@ -45,8 +45,12 @@ class LHS::Record
45
45
  Chain.new(self, ErrorHandling.new(error_class => handler))
46
46
  end
47
47
 
48
- def ignore(error_class)
49
- Chain.new(self, IgnoredError.new(error_class))
48
+ def ignore(*error_classes)
49
+ chain = Chain.new(self, IgnoredError.new(error_classes.shift))
50
+ error_classes.each do |error_class|
51
+ chain._links.push(IgnoredError.new(error_class))
52
+ end
53
+ chain
50
54
  end
51
55
 
52
56
  def includes(*args)
@@ -201,8 +205,12 @@ class LHS::Record
201
205
  push(Option.new(hash))
202
206
  end
203
207
 
204
- def ignore(error_class)
205
- push(IgnoredError.new(error_class))
208
+ def ignore(*error_classes)
209
+ chain = push(IgnoredError.new(error_classes.shift))
210
+ error_classes.each do |error_class|
211
+ chain._links.push(IgnoredError.new(error_class))
212
+ end
213
+ chain
206
214
  end
207
215
 
208
216
  def page(page)
@@ -381,7 +389,7 @@ class LHS::Record
381
389
  end
382
390
 
383
391
  def chain_pagination
384
- @chain_pagination ||= resolve_pagination _links.select { |link| link.is_a? Pagination }
392
+ @chain_pagination ||= resolve_pagination(_links.select { |link| link.is_a? Pagination })
385
393
  end
386
394
 
387
395
  def chain_includes
@@ -22,7 +22,7 @@ class LHS::Record
22
22
  private
23
23
 
24
24
  def filter_empty_request_options(options)
25
- options.each_with_index.map do |option|
25
+ options.map do |option|
26
26
  option if !option || !option.key?(:url) || !option[:url].nil?
27
27
  end
28
28
  end
data/lib/lhs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = "13.1.0"
2
+ VERSION = "13.2.0"
3
3
  end
@@ -11,11 +11,8 @@ describe LHS::Record do
11
11
  end
12
12
 
13
13
  context 'ignore errors' do
14
- before(:each) do
15
- stub_request(:get, "http://local.ch/v2/records?color=blue").to_return(status: 404)
16
- end
17
-
18
14
  it 'allows to ignore errors' do
15
+ stub_request(:get, "http://local.ch/v2/records?color=blue").to_return(status: 404)
19
16
  record = Record
20
17
  .where(color: 'blue')
21
18
  .ignore(LHC::NotFound)
@@ -54,4 +51,31 @@ describe LHS::Record do
54
51
  .fetch
55
52
  expect(record).to eq nil
56
53
  end
54
+
55
+ it 'can ignore multiple error with one ignore call' do
56
+ stub_request(:get, "http://local.ch/v2/records?color=blue").to_return(status: 401)
57
+ record = Record
58
+ .ignore(LHC::Unauthorized, LHC::NotFound)
59
+ .where(color: 'blue')
60
+ .fetch
61
+ expect(record).to eq nil
62
+ end
63
+
64
+ it 'can ignore multiple error with one ignore call, on chain start' do
65
+ stub_request(:get, "http://local.ch/v2/records?color=blue").to_return(status: 401)
66
+ record = Record
67
+ .ignore(LHC::Unauthorized, LHC::NotFound)
68
+ .where(color: 'blue')
69
+ .fetch
70
+ expect(record).to eq nil
71
+ end
72
+
73
+ it 'can ignore multiple error with one ignore call, also within the chain' do
74
+ stub_request(:get, "http://local.ch/v2/records?color=blue").to_return(status: 401)
75
+ record = Record
76
+ .where(color: 'blue')
77
+ .ignore(LHC::Unauthorized, LHC::NotFound)
78
+ .fetch
79
+ expect(record).to eq nil
80
+ end
57
81
  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: 13.1.0
4
+ version: 13.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors