Module: RemotelyExceptional::Handler::ClassMethods
- Defined in:
- lib/remotely_exceptional/handler.rb
Overview
Class-level handler behaviors that will be added to any object that includes this module.
Instance Method Summary collapse
-
#===(exception) ⇒ Boolean
Used by Ruby’s rescue keyword to evaluate if an exception instance can be caught by this Class or Module.
-
#handle(exception = $!, context = {}) ⇒ Symbol
Factory method that takes in an exception and an optional Hash of additional contextual information and creates a new Handler instance from that data.
Instance Method Details
#===(exception) ⇒ Boolean
Used by Ruby’s rescue keyword to evaluate if an exception instance can be caught by this Class or Module. Delegates to #matcher.
42 43 44 |
# File 'lib/remotely_exceptional/handler.rb', line 42 def ===(exception) matcher.call(exception) end |
#handle(exception = $!, context = {}) ⇒ Symbol
Factory method that takes in an exception and an optional Hash of additional contextual information and creates a new Handler instance from that data. The generated Handler instance is then used to handle the the exception.
57 58 59 60 61 62 63 |
# File 'lib/remotely_exceptional/handler.rb', line 57 def handle(exception = $!, context = {}) instance = new context, exception = exception, $! if exception.is_a?(Hash) instance.instance_variable_set(:@exception, exception) instance.instance_variable_set(:@context, context) instance.handle end |