Module: Kernel

Defined in:
lib/m_kernel.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.pp_to_s(object) ⇒ Object



6
7
8
9
10
# File 'lib/m_kernel.rb', line 6

def self.pp_to_s(object)
  pp_out = StringIO.new
  PP.pp(object,pp_out)
  return pp_out.string
end

Instance Method Details

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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/m_kernel.rb', line 12

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

  retries = opts[:tries]
  retry_exceptions = [opts[:on]].flatten
  
  x = %{
    begin
      return yield
    rescue #{retry_exceptions.join(", ")} => e
      retries -= 1
      retry if retries > 0
    end        
  }

  eval(x, &block)
end