summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCosmicOppai <[email protected]>2024-10-15 06:21:18 +0530
committergit <[email protected]>2024-12-03 06:49:55 +0000
commite7dd185e2147ff0ce5ad6a3de563749a4ad8ccb2 (patch)
treea0eb3f322db4884197f9f9a9eb72f95463e32de3 /lib
parent0839eae2d362b70d1b36b939b7ad6aa809a618a9 (diff)
[ruby/timeout] refactor the change to raise for nil and type-errror and added tests
https://github.com/ruby/timeout/commit/ffc8d7c003
Diffstat (limited to 'lib')
-rw-r--r--lib/timeout.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 59437f490e..56d31db61a 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -164,8 +164,8 @@ module Timeout
# Timeout</tt> into your classes so they have a #timeout method, as well as
# a module method, so you can call it directly as Timeout.timeout().
def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
- raise ArgumentError, "Timeout sec must be a positive number" if sec.is_a?(Numeric) && sec < 0
- return yield(sec) if sec == nil or sec.zero?
+ raise ArgumentError, "Timeout sec must be a positive number" unless sec.is_a?(Numeric) && sec >= 0
+ return yield(sec) if sec.zero?
message ||= "execution expired"