Class: GenevaDrive::ExceptionPolicy::LazyExceptionMatcher Private
- Inherits:
-
Object
- Object
- GenevaDrive::ExceptionPolicy::LazyExceptionMatcher
- Defined in:
- lib/geneva_drive/exception_policy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Matches exceptions by class name without requiring the constant to be loaded at definition time. The class lookup happens lazily on each #=== call. If the constant cannot be resolved, the matcher returns false (no match) rather than raising.
Instance Method Summary collapse
- #===(error) ⇒ Boolean private
-
#initialize(class_name) ⇒ LazyExceptionMatcher
constructor
private
A new instance of LazyExceptionMatcher.
- #inspect ⇒ Object private
Constructor Details
#initialize(class_name) ⇒ LazyExceptionMatcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of LazyExceptionMatcher.
53 54 55 |
# File 'lib/geneva_drive/exception_policy.rb', line 53 def initialize(class_name) @class_name = class_name.to_s.freeze end |
Instance Method Details
#===(error) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 |
# File 'lib/geneva_drive/exception_policy.rb', line 59 def ===(error) klass = @class_name.safe_constantize klass ? error.is_a?(klass) : false end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 |
# File 'lib/geneva_drive/exception_policy.rb', line 64 def inspect "#<LazyExceptionMatcher #{@class_name}>" end |