Class: Rack::ECG::CheckFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/ecg/check_factory.rb

Defined Under Namespace

Classes: CheckDefinition

Instance Method Summary collapse

Constructor Details

#initialize(definitions, default_checks = []) ⇒ CheckFactory

Returns a new instance of CheckFactory.



10
11
12
13
14
15
16
# File 'lib/rack/ecg/check_factory.rb', line 10

def initialize(definitions, default_checks = [])
  definitions = Array(definitions) | default_checks

  @checks = definitions.map do |check_name, check_parameters|
    CheckDefinition.new(CheckRegistry.lookup(check_name), check_parameters)
  end
end

Instance Method Details

#build(check_class, parameters = nil) ⇒ Object



24
25
26
# File 'lib/rack/ecg/check_factory.rb', line 24

def build(check_class, parameters = nil)
  parameters.nil? ? check_class.new : check_class.new(parameters)
end

#build_allObject



18
19
20
21
22
# File 'lib/rack/ecg/check_factory.rb', line 18

def build_all
  @checks.map do |check_definition|
    build(check_definition.check_class, check_definition.parameters)
  end
end