Skip to content

Commit 281249c

Browse files
author
md-work
committed
Second debugging version of previous commit (40fc4ae), to wrap &blocks only when there is a Func check. (bug 278)
1 parent f02270d commit 281249c

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

lib/contracts/call_with.rb

+3-13
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,9 @@ def call_with_inner(returns, this, *args, &blk)
8181
method.call(*args, &blk)
8282
else
8383
# original method name reference
84-
target_block = nil
85-
blk_is_contract = false
86-
if blk
87-
if blk.is_a?(Contract) # rubocop:disable Style/IfUnlessModifier
88-
blk_is_contract = true
89-
end
90-
end
91-
if blk_is_contract # rubocop:disable Style/ConditionalAssignment
92-
target_block = lambda { |*params| blk.call(*params) }
93-
else
94-
target_block = blk
95-
end
96-
method.send_to(this, *args, &target_block)
84+
target_blk = blk
85+
target_blk = lambda { |*params| blk.call(*params) } if blk_is_contract
86+
method.send_to(this, *args, &target_blk)
9787
end
9888

9989
unless @ret_validator[result]

0 commit comments

Comments
 (0)