Class: Rubyzen::Collections::RescuesCollection

Inherits:
BaseCollection show all
Defined in:
lib/rubyzen/collections/rescues_collection.rb

Overview

Collection of rescue declarations found in methods or classes.

Examples:

Checking for StandardError rescues

project.files.classes.all_methods.rescues.with_exception_type('StandardError')

Instance Method Summary collapse

Methods inherited from BaseCollection

#filter

Instance Method Details

#with_exception_type(exception_class) ⇒ RescuesCollection

Filters rescues that handle the given exception class.

Parameters:

  • exception_class (String)

    the exception class name to match

Returns:



12
13
14
15
16
# File 'lib/rubyzen/collections/rescues_collection.rb', line 12

def with_exception_type(exception_class)
  filter do |rescue_declaration|
    rescue_declaration.exception_types.include?(exception_class)
  end
end