Module: Kernel
- Defined in:
- lib/extensions/kernel.rb
Instance Method Summary collapse
Instance Method Details
#pp_to_s(object) ⇒ Object
6 7 8 9 10 |
# File 'lib/extensions/kernel.rb', line 6 def pp_to_s(object) pp_out = StringIO.new PP.pp(object,pp_out) return pp_out.string end |
#retryable(options = {}, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/extensions/kernel.rb', line 12 def retryable( = {}, &block) opts = { :tries => 1, :on => Exception }.merge() retries = opts[:tries] retry_exceptions = [opts[:on]].flatten x = %{ begin return yield rescue #{retry_exceptions.join(", ")} => e retries -= 1 if retries > 0 retry else raise e end end } eval(x, &block) end |