Class: OkComputer::Checks::Registry

Inherits:
Registry
  • Object
show all
Defined in:
lib/ok_computer/checks/registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection = nil) ⇒ Registry

rubocop:disable Lint/MissingSuper



16
17
18
19
20
21
22
23
24
# File 'lib/ok_computer/checks/registry.rb', line 16

def initialize(collection = nil) # rubocop:disable Lint/MissingSuper
  self.collection = if collection.is_a?(CheckCollection)
    collection
  elsif collection
    ::OkComputer::Registry.default_collection.fetch(collection) || CheckCollection.new(collection)
  else
    ::OkComputer::Registry.default_collection
  end
end

Instance Attribute Details

#collectionObject

Returns the value of attribute collection.



12
13
14
# File 'lib/ok_computer/checks/registry.rb', line 12

def collection
  @collection
end

Instance Method Details

#add(klass_or_check, check_name, **args) ⇒ Object



36
37
38
# File 'lib/ok_computer/checks/registry.rb', line 36

def add(klass_or_check, check_name, **args)
  register(check_name, process_check(klass_or_check, **args))
end

#add_collection(collection_name, &block) ⇒ Object



26
27
28
29
30
# File 'lib/ok_computer/checks/registry.rb', line 26

def add_collection(collection_name, &block)
  checks = CheckCollection.new(collection_name)
  Checks.register(checks, &block)
  register(collection_name, checks)
end

#add_optional(klass_or_check, check_name, **args) ⇒ Object



32
33
34
# File 'lib/ok_computer/checks/registry.rb', line 32

def add_optional(klass_or_check, check_name, **args)
  add(OptionalCheck.new(process_check(klass_or_check, **args)), check_name)
end