class OkComputer::Registry
Constants
- CheckNotFound
-
used when fetching a check that has not been registered
- CollectionNotFound
Public Class Methods
Source
# File lib/ok_computer/registry.rb, line 21 def self.all default_collection end
Public: Return an object containing all the registered checks
Returns the default_collection
CheckCollection
instance
Source
# File lib/ok_computer/registry.rb, line 33 def self.default_collection @default_collection ||= CheckCollection.new('Default Collection') end
Public: The default collection of checks
Returns @default_collection
Source
# File lib/ok_computer/registry.rb, line 50 def self.deregister(check_name, collection_name=nil) find_collection(collection_name).deregister(check_name) end
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
Source
# File lib/ok_computer/registry.rb, line 12 def self.fetch(name) default_collection.fetch(name) rescue KeyError raise CheckNotFound, "No matching check" end
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
Source
# File lib/ok_computer/registry.rb, line 54 def self.find_collection(collection_name=nil) collection_name ? default_collection.fetch(collection_name) : default_collection rescue KeyError raise CollectionNotFound end
Source
# 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
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