Class: Pennyworth::Loaders::StandardError

Inherits:
Object
  • Object
show all
Defined in:
lib/pennyworth/loaders/standard_error.rb

Overview

Loads an array of standard error records.

Instance Method Summary collapse

Constructor Details

#initialize(root: ::StandardError, model: Models::StandardError) ⇒ StandardError

Returns a new instance of StandardError.



7
8
9
10
# File 'lib/pennyworth/loaders/standard_error.rb', line 7

def initialize root: ::StandardError, model: Models::StandardError
  @root = root
  @model = model
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
# File 'lib/pennyworth/loaders/standard_error.rb', line 12

def call(*)
  ObjectSpace.each_object(Class)
             .select { |klass| klass < root }
             .sort_by(&:name)
             .map do |error|
               file_path, line_number = Object.const_source_location error.name
               model[name: error, file_path:, line_number:]
             end
end