class Gracefully::RetriedCommand

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method Gracefully::Command::new
# File lib/gracefully/retried_command.rb, line 5
def initialize(*args, &block)
  super

  @retries = @options[:retries]
end

Public Instance Methods

call(*args, &block) click to toggle source
# File lib/gracefully/retried_command.rb, line 11
def call(*args, &block)
  num_tried = 0
  begin
    @callable.call *args, &block
  rescue => e
    num_tried += 1
    if num_tried <= @retries
      retry
    else
      raise Gracefully::Error.new(e.message, nested: e)
    end
  end
end