module Gateway::Feature::Retry
Protected Instance Methods
retry?()
click to toggle source
# File lib/gateway/feature/retry.rb, line 36 def retry? @retry ||= options.fetch(:retry, true) end
retry_error?(action, error)
click to toggle source
# File lib/gateway/feature/retry.rb, line 22 def retry_error?(action, error) error = error.inner_error if error.is_a?(Gateway::Error) errors = retry_errors(action) errors.any?{ |klass| error.is_a?(klass) } end
retry_errors(action)
click to toggle source
# File lib/gateway/feature/retry.rb, line 28 def retry_errors(action) raise "Abstract Method" end
run_retry_callbacks(action)
click to toggle source
# File lib/gateway/feature/retry.rb, line 32 def run_retry_callbacks(action) raise "Abstract Method" end
with_retry(action, opts={}, &block)
click to toggle source
# File lib/gateway/feature/retry.rb, line 6 def with_retry(action, opts={}, &block) return block.call unless opts.fetch(:retry, retry?) retried = false begin block.call rescue => e if !retried && retry_error?(action, e) run_retry_callbacks(action) retried = true retry end raise end end