Skip to content

Commit 544c29e

Browse files
committed
Rewrite #instrument
Only yields if block is given so #instrument can be called without one. Clarifies conditional behavior when service is set.
1 parent fcdd78b commit 544c29e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/net/ldap/instrumentation.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ module Net::LDAP::Instrumentation
66
#
77
# Returns the return value of the block.
88
def instrument(event, payload = {})
9-
return yield(payload) unless instrumentation_service
10-
11-
instrumentation_service.instrument(event, payload) do |payload|
12-
payload[:result] = yield(payload)
9+
if instrumentation_service
10+
instrumentation_service.instrument(event, payload) do |payload|
11+
payload[:result] = yield(payload) if block_given?
12+
end
13+
else
14+
yield(payload) if block_given?
1315
end
1416
end
1517
private :instrument

0 commit comments

Comments
 (0)