return_safe_yield 0.1.2 → 0.1.3

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: 9a8d1d2fc51037060163ec294e01999a0a5ba28e
4
- data.tar.gz: ac364d3f04d1a76905da98ff298a6982dd0f4f58
3
+ metadata.gz: 7f73d9b9521f322cca377a84aa766a4006f95cc7
4
+ data.tar.gz: 96ea5ebb0d4267da8accef740e9bcc10ab968243
5
5
  SHA512:
6
- metadata.gz: 358b653afe13a86fc382ca8f5d309ac08c794f80a30207eeb1072afe2759ac26e458cdb2f8b303235fdad4dd081bdabbbf4276082dffbefa751fc14697b1a141
7
- data.tar.gz: efc7867b9e5cd3a988e75d873eb74cec8b9cc50c4d8434369a2468fb918b8c292694e6d04128ed6c9a01ad99de30bae208f80928542a777797cfa931efa1fe1a
6
+ metadata.gz: e7a9c5064afa37b4fae41e81ad4c87a05bf93dd82eb0a935888c214b6c308348caa02cbaf24a374ee88a12ab6f177092a6d35e470d775fc0a0421e31ecbc56e9
7
+ data.tar.gz: 2d8d9fff6fdadb5002c7729bead57897b7609e931ac220d901a664eed62dc91330d0847999fff8caa4d734d1725cef96da8ddd51259076f28a9f5ea9279360ea
@@ -1,3 +1,3 @@
1
1
  module ReturnSafeYield
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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 yield(*first_block_result)
60
+ return second_block_result unless returned
56
61
  end
57
62
  end
58
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: return_safe_yield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Fritzsche