Class: OkComputer::Registry
- Inherits:
-
Object
- Object
- OkComputer::Registry
- Defined in:
- lib/ok_computer/registry.rb
Constant Summary collapse
- CheckNotFound =
used when fetching a check that has not been registered
Class.new(StandardError)
Class Method Summary collapse
-
.all ⇒ Object
Public: Return an object containing all the registered checks.
-
.deregister(check_name) ⇒ Object
Public: Remove the check of the given name being checked.
-
.fetch(check_name) ⇒ Object
Public: Return the check registered to the given name.
-
.register(check_name, check_object) ⇒ Object
Public: Register the given check with OkComputer.
-
.registry ⇒ Object
Private: The list of registered checks, keyed by their unique names.
Class Method Details
.all ⇒ Object
Public: Return an object containing all the registered checks
Returns a CheckCollection instance
21 22 23 |
# File 'lib/ok_computer/registry.rb', line 21 def self.all CheckCollection.new registry end |
.deregister(check_name) ⇒ Object
Public: Remove the check of the given name being checked
check_name - The name of the check to retrieve
37 38 39 |
# File 'lib/ok_computer/registry.rb', line 37 def self.deregister(check_name) registry.delete(check_name) end |
.fetch(check_name) ⇒ Object
Public: Return the check registered to the given name
check_name - The name of the check to retrieve
Returns the registered check or raises Registry::CheckNotFound
12 13 14 15 16 |
# File 'lib/ok_computer/registry.rb', line 12 def self.fetch(check_name) registry.fetch(check_name) rescue KeyError raise CheckNotFound, "No check registered with '#{check_name}'" end |
.register(check_name, check_object) ⇒ Object
Public: Register the given check with OkComputer
check_name - The name of the check to retrieve check_object - Instance of Checker to register
29 30 31 32 |
# File 'lib/ok_computer/registry.rb', line 29 def self.register(check_name, check_object) check_object.registrant_name = check_name registry[check_name] = check_object end |
.registry ⇒ Object
Private: The list of registered checks, keyed by their unique names
Returns a Hash
44 45 46 |
# File 'lib/ok_computer/registry.rb', line 44 def self.registry @registry ||= {} end |