module Gateway::Feature::Timeout
Constants
- DEFAULT_TIMEOUT
Public Instance Methods
timeout()
click to toggle source
# File lib/gateway/feature/timeout.rb, line 6 def timeout @timeout ||= options.fetch :timeout, Gateway::Feature::Timeout::DEFAULT_TIMEOUT end
Protected Instance Methods
with_timeout(opts={}, &block)
click to toggle source
# File lib/gateway/feature/timeout.rb, line 13 def with_timeout(opts={}, &block) t = opts.fetch(:timeout, timeout) return block.call if t == false # if the timeout is 0 or negative, timeout is raised # without executing the block raise ::Timeout::Error if t <= 0 ::Timeout.timeout(t){ block.call } end