module Porch::Rescuable
Public Class Methods
included(base)
click to toggle source
# File lib/porch/rescuable.rb, line 48 def self.included(base) base.extend ClassMethods end
Public Instance Methods
handle_exceptions() { || ... }
click to toggle source
# File lib/porch/rescuable.rb, line 3 def handle_exceptions yield if block_given? rescue Exception => e rescue_with_handler(e) || raise(e) end
handler_for_rescue(exception)
click to toggle source
# File lib/porch/rescuable.rb, line 9 def handler_for_rescue(exception) _, handler = self.class.rescue_handlers.detect do |exception_class, _| exception_class === exception end handler end
rescue_with_handler(exception)
click to toggle source
# File lib/porch/rescuable.rb, line 17 def rescue_with_handler(exception) handler = handler_for_rescue(exception) unless handler.nil? case handler when Symbol self.method(handler).call exception when Proc self.instance_exec exception, &handler end exception end end