Class: KStor::ErrorRegistry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/kstor/error.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Basically an Array of error subclasses, with an index on error codes.

Instance Method Summary collapse

Constructor Details

#initializeErrorRegistry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create new registry.



86
87
88
89
# File 'lib/kstor/error.rb', line 86

def initialize
  @error_classes = []
  @index = nil
end

Instance Method Details

#<<(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Append an error class.



97
98
99
100
# File 'lib/kstor/error.rb', line 97

def <<(klass)
  @error_classes << klass
  @index = nil
end

#[](code) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return subclass for this error code.



108
109
110
# File 'lib/kstor/error.rb', line 108

def [](code)
  index[code]
end

#classesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

List of subclasses.



92
93
94
# File 'lib/kstor/error.rb', line 92

def classes
  @error_classes.values
end

#key?(code) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

True if registry knows a subclass with this error code.

Returns:

  • (Boolean)


103
104
105
# File 'lib/kstor/error.rb', line 103

def key?(code)
  index.key?(code)
end