class OkComputer::Registry

Constants

CheckNotFound

used when fetching a check that has not been registered

CollectionNotFound

Public Class Methods

all() click to toggle source

Public: Return an object containing all the registered checks

Returns the default_collection CheckCollection instance

# File lib/ok_computer/registry.rb, line 21
def self.all
  default_collection
end
default_collection() click to toggle source

Public: The default collection of checks

Returns @default_collection

# 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) click to toggle source

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

# 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) click to toggle source

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

# 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) click to toggle source

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

# 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

Private Class Methods

find_collection(collection_name=nil) click to toggle 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