Skip to content

Commit 2b0b3d9

Browse files
committed
Merge branch 'hotfix-1.1.1'
2 parents cf86cd8 + 652ad51 commit 2b0b3d9

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
fast_jsonapi (1.1.0)
4+
fast_jsonapi (1.1.1)
55
activesupport (>= 4.2)
66

77
GEM

fast_jsonapi.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |gem|
22
gem.name = "fast_jsonapi"
3-
gem.version = "1.1.0"
3+
gem.version = "1.1.1"
44

55
gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
66
gem.metadata = { "allowed_push_host" => "https://rubygems.org" } if gem.respond_to? :metadata=

lib/fast_jsonapi/multi_to_json.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ module MultiToJson
1212
# e.g. https://github.com/github/github-ds/blob/fbda5389711edfb4c10b6c6bad19311dfcb1bac1/lib/github/result.rb
1313
class Result
1414
def initialize(*rescued_exceptions)
15-
rescued_exceptions = [StandardError] if rescued_exceptions.empty?
15+
@rescued_exceptions = if rescued_exceptions.empty?
16+
[StandardError]
17+
else
18+
rescued_exceptions
19+
end
20+
1621
@value = yield
1722
@error = nil
1823
rescue *rescued_exceptions => e
@@ -33,7 +38,8 @@ def value!
3338

3439
def rescue
3540
return self if ok?
36-
Result.new { yield(@error) }
41+
42+
Result.new(*@rescued_exceptions) { yield(@error) }
3743
end
3844
end
3945

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'spec_helper'
2+
3+
module FastJsonapi
4+
module MultiToJson
5+
describe Result do
6+
it 'supports chaining of rescues' do
7+
expect do
8+
Result.new(LoadError) do
9+
require '1'
10+
end.rescue do
11+
require '2'
12+
end.rescue do
13+
require '3'
14+
end.rescue do
15+
'4'
16+
end
17+
end.not_to raise_error
18+
end
19+
end
20+
end
21+
end

0 commit comments

Comments
 (0)