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 +4 -4
- data/README.md +1 -1
- data/lib/lhs/concerns/record/chainable.rb +13 -5
- data/lib/lhs/concerns/record/request.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/record/ignore_errors_spec.rb +28 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d47809d2cae46a30a0e8e5fb00efc3f739b81d42
|
4
|
+
data.tar.gz: 8c8aa4ec034214fc41b036de60adefcdb5b50d8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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(
|
49
|
-
Chain.new(self, IgnoredError.new(
|
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(
|
205
|
-
push(IgnoredError.new(
|
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
|
392
|
+
@chain_pagination ||= resolve_pagination(_links.select { |link| link.is_a? Pagination })
|
385
393
|
end
|
386
394
|
|
387
395
|
def chain_includes
|
data/lib/lhs/version.rb
CHANGED
@@ -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
|