Class: Longleaf::ServiceDefinitionValidator
- Inherits:
-
ConfigurationValidator
- Object
- ConfigurationValidator
- Longleaf::ServiceDefinitionValidator
- Defined in:
- lib/longleaf/services/service_definition_validator.rb
Overview
Validates application configuration of service definitions
Class Method Summary collapse
-
.validate_config(config) ⇒ Object
Validates configuration to ensure that it is syntactically correct and does not violate schema requirements.
Methods inherited from ConfigurationValidator
Class Method Details
.validate_config(config) ⇒ Object
Validates configuration to ensure that it is syntactically correct and does not violate schema requirements.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/longleaf/services/service_definition_validator.rb', line 16 def self.validate_config(config) assert("Configuration must be a hash, but a #{config.class} was provided", config.class == Hash) assert("Configuration must contain a root '#{AF::SERVICES}' key", config.key?(AF::SERVICES)) services = config[AF::SERVICES] assert("'#{AF::SERVICES}' must be a hash of services", services.class == Hash) services.each do |name, properties| assert("Name of service definition must be a string, but was of type #{name.class}", name.instance_of?(String)) assert("Service definition '#{name}' must be a hash, but a #{properties.class} was provided", properties.is_a?(Hash)) work_script = properties[SF::WORK_SCRIPT] assert("Service definition '#{name}' must specify a '#{SF::WORK_SCRIPT}' property", !work_script.nil? && !work_script.empty?) end end |