Module: TimeLimits::Timeout
Instance Method Summary collapse
- #in_time(duration = 1, &block) ⇒ Object
-
#in_time_or_else(duration = 1, options = {}, &block) ⇒ Object
options :rescue value.
Instance Method Details
#in_time(duration = 1, &block) ⇒ Object
11 12 13 |
# File 'lib/time_limits/timeout.rb', line 11 def in_time( duration = 1, &block ) SystemTimer.timeout_after(duration) { yield } end |
#in_time_or_else(duration = 1, options = {}, &block) ⇒ Object
options :rescue value
24 25 26 27 28 |
# File 'lib/time_limits/timeout.rb', line 24 def in_time_or_else( duration = 1, = {}, &block ) in_time( duration, &block ) rescue ::Timeout::Error => x return [:rescue] end |