Class: AttemptThis::ExceptionTypeFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/attempt_this/exception_type_filter.rb

Overview

Type-based exception filter.

Instance Method Summary collapse

Constructor Details

#initialize(exception_classes) ⇒ ExceptionTypeFilter

Initializer.



5
6
7
# File 'lib/attempt_this/exception_type_filter.rb', line 5

def initialize(exception_classes)
  @exception_classes = Array.new(exception_classes)
end

Instance Method Details

#include?(exception) ⇒ Boolean

Tells whether the given exception satisfies the filter.

Returns:

  • (Boolean)


10
11
12
# File 'lib/attempt_this/exception_type_filter.rb', line 10

def include?(exception)
  @exception_classes.any?{|klass| exception.is_a?(klass)}
end