Class: Wire::AppGroupValidation

Inherits:
ValidationBase show all
Defined in:
lib/wire/model/appgroup_validation.rb

Overview

Run validations on appgroup model part

Instance Attribute Summary

Attributes inherited from ValidationBase

#errors

Instance Method Summary collapse

Methods inherited from ValidationBase

#initialize, #mark, #objects_attached_to_zones?

Constructor Details

This class inherits a constructor from Wire::ValidationBase

Instance Method Details

#appgroups_attached_to_zones?Boolean

ensures that all application groups are attached to a zone

Returns:

  • (Boolean)


22
23
24
# File 'lib/wire/model/appgroup_validation.rb', line 22

def appgroups_attached_to_zones?
  objects_attached_to_zones? 'appgroups'
end

#controllers_valid?Boolean

ensures that all application groups have a known controller

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/wire/model/appgroup_validation.rb', line 27

def controllers_valid?
  @project.get_element('appgroups').each do |appgroup_name, appgroup_data|
    controller_data = appgroup_data[:controller]
    type = 'appgroup'
    name = appgroup_name
    if !controller_data
      mark('Appgroup is not attached to a zone', type, name)
    else
      type = controller_data[:type]
      mark('Appgroup controller does not have a type', type, name) unless type && type.size > 0

      known_types = %w(fig)
      mark('Appgroup controller has an unkown type (#{type})',
           type, name) unless known_types.include?(type)
    end
  end
end

#run_validationsObject

run validation steps on appgroup elements returns

  • nil, results in errors of ValidationBase



14
15
16
17
18
19
# File 'lib/wire/model/appgroup_validation.rb', line 14

def run_validations
  return unless @project.element?('appgroups')

  appgroups_attached_to_zones?
  controllers_valid?
end