Class: MethodDecorators::Within
- Defined in:
- lib/method_decorators/within.rb
Instance Method Summary collapse
- #call(orig, this, *args, &blk) ⇒ Object
-
#initialize(timeout, exception_class = nil) ⇒ Within
constructor
A new instance of Within.
Methods inherited from Decorator
Constructor Details
#initialize(timeout, exception_class = nil) ⇒ Within
Returns a new instance of Within.
6 7 8 9 |
# File 'lib/method_decorators/within.rb', line 6 def initialize(timeout, exception_class = nil) @seconds = timeout @exception_class = exception_class end |
Instance Method Details
#call(orig, this, *args, &blk) ⇒ Object
11 12 13 14 15 |
# File 'lib/method_decorators/within.rb', line 11 def call(orig, this, *args, &blk) Timeout.timeout(@seconds, @exception_class) do orig.call(*args, &blk) end end |