Class: Rack::ECG::CheckFactory
- Inherits:
-
Object
- Object
- Rack::ECG::CheckFactory
- Defined in:
- lib/rack/ecg/check_factory.rb
Defined Under Namespace
Classes: CheckDefinition
Instance Method Summary collapse
- #build(check_class, parameters = nil) ⇒ Object
- #build_all ⇒ Object
-
#initialize(definitions, default_checks = []) ⇒ CheckFactory
constructor
A new instance of CheckFactory.
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_all ⇒ Object
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 |