Class: Pennyworth::Loaders::System::Error

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

Overview

Loads an array of system error records.

Instance Method Summary collapse

Constructor Details

#initialize(errno: Errno, model: Models::System::Error) ⇒ Error

Returns a new instance of Error.



8
9
10
11
# File 'lib/pennyworth/loaders/system/error.rb', line 8

def initialize errno: Errno, model: Models::System::Error
  @errno = errno
  @model = model
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
# File 'lib/pennyworth/loaders/system/error.rb', line 13

def call(*)
  errno.constants
       .map { |name| errno.const_get name }
       .uniq
       .sort_by { |error| error::Errno }
       .map do |error|
         model[id: error::Errno, name: error.name, description: error.exception.message]
       end
end