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)
- CollectionNotFound =
Class.new(StandardError)
Class Method Summary collapse
-
.all ⇒ Object
Public: Return an object containing all the registered checks.
-
.default_collection ⇒ Object
Public: The default collection of checks.
-
.deregister(check_name, collection_name = nil) ⇒ Object
Public: Remove the check of the given name being checked.
-
.fetch(name) ⇒ Object
Public: Return the check registered to the given name.
-
.register(check_name, check_object, collection_name = nil) ⇒ Object
Public: Register the given check with OkComputer.
Class Method Details
.all ⇒ Object
Public: Return an object containing all the registered checks
Returns the default_collection CheckCollection instance
21 22 23 |
# File 'lib/ok_computer/registry.rb', line 21 def self.all default_collection end |
.default_collection ⇒ Object
Public: The default collection of checks
Returns @default_collection
33 34 35 |
# File 'lib/ok_computer/registry.rb', line 33 def self.default_collection @default_collection ||= CheckCollection.new('Default Collection') end |
.deregister(check_name, collection_name = nil) ⇒ Object
Public: Remove the check of the given name being checked
check_name - The name of the check to retrieve collection_name - The name of the check collection the check should be deregistered from
50 51 52 |
# File 'lib/ok_computer/registry.rb', line 50 def self.deregister(check_name, collection_name=nil) find_collection(collection_name).deregister(check_name) end |
.fetch(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(name) default_collection.fetch(name) rescue KeyError raise CheckNotFound, "No matching check" end |
.register(check_name, check_object, collection_name = nil) ⇒ Object
Public: Register the given check with OkComputer
check_name - The name of the check to retrieve check_object - Instance of Checker to register collection_name - The name of the check collection the check should be registered to
42 43 44 |
# File 'lib/ok_computer/registry.rb', line 42 def self.register(check_name, check_object, collection_name=nil) find_collection(collection_name).register(check_name, check_object) end |