Module: Morale::Flow

Included in:
Account, Commands::Ticket
Defined in:
lib/morale/flow.rb

Instance Method Summary collapse

Instance Method Details

#retryable(options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/morale/flow.rb', line 3

def retryable(options = {}, &block)
  opts = { :tries => 1, :indefinate => false, :on => Exception }.merge(options)

  retry_exception, retries, indefinately = opts[:on], opts[:tries], opts[:indefinate]

  begin
    return yield
  rescue retry_exception
    retry if indefinately || (retries -= 1) > 0
  end

  yield
end