Sha256: c81c7c91955a8596b8a10964f85a57d3e68d68e330feea4b2bb062ef7756a0fe

Contents?: true

Size: 697 Bytes

Versions: 17

Compression:

Stored size: 697 Bytes

Contents

# frozen_string_literal: true

module Pennyworth
  module Loaders
    # Loads an array of standard error records.
    class StandardError
      def initialize root: ::StandardError, model: Models::StandardError
        @root = root
        @model = model
      end

      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

      private

      attr_reader :root, :model
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pennyworth-17.8.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.7.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.6.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.5.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.4.1 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.4.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.3.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.2.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.1.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-17.0.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-16.7.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-16.5.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-16.4.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-16.3.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-16.2.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-16.1.0 lib/pennyworth/loaders/standard_error.rb
pennyworth-16.0.0 lib/pennyworth/loaders/standard_error.rb