return_safe_yield 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/return_safe_yield/version.rb +1 -1
- data/lib/return_safe_yield.rb +6 -1
- 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: 7f73d9b9521f322cca377a84aa766a4006f95cc7
|
4
|
+
data.tar.gz: 96ea5ebb0d4267da8accef740e9bcc10ab968243
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7a9c5064afa37b4fae41e81ad4c87a05bf93dd82eb0a935888c214b6c308348caa02cbaf24a374ee88a12ab6f177092a6d35e470d775fc0a0421e31ecbc56e9
|
7
|
+
data.tar.gz: 2d8d9fff6fdadb5002c7729bead57897b7609e931ac220d901a664eed62dc91330d0847999fff8caa4d734d1725cef96da8ddd51259076f28a9f5ea9279360ea
|
data/lib/return_safe_yield.rb
CHANGED
@@ -42,17 +42,22 @@ module ReturnSafeYield
|
|
42
42
|
def self.call_then_yield(first, *args, &_second)
|
43
43
|
exception = false
|
44
44
|
first_block_result = nil
|
45
|
+
returned = true
|
45
46
|
begin
|
46
47
|
first_block_result = first.call(*args)
|
48
|
+
returned = false
|
49
|
+
return first_block_result
|
47
50
|
rescue
|
48
51
|
exception = true
|
49
52
|
fail
|
50
53
|
ensure
|
51
54
|
unless exception
|
55
|
+
second_block_result = yield(*first_block_result)
|
56
|
+
|
52
57
|
# In this very particular case, using `return` inside of `ensure`
|
53
58
|
# is fine as we're checking if there is an exception. There is no other
|
54
59
|
# way of returning the second block's result otherwise.
|
55
|
-
return
|
60
|
+
return second_block_result unless returned
|
56
61
|
end
|
57
62
|
end
|
58
63
|
end
|