Class: Etna::Clients::Magma::AttributeActionsValidator
Instance Attribute Summary collapse
#errors
Instance Method Summary
collapse
#check_in_set, #check_key, #check_valid_name_with_numbers, #format_errors, #model_exists_in_project?, #name_regex_no_numbers, #name_regex_with_numbers, #nil_or_empty?, #valid?, #validate!
Constructor Details
Returns a new instance of AttributeActionsValidator.
413
414
415
416
417
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 413
def initialize(actions, project_models)
super()
@actions = actions
@project_models = project_models
end
|
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
411
412
413
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 411
def actions
@actions
end
|
#project_models ⇒ Object
Returns the value of attribute project_models.
411
412
413
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 411
def project_models
@project_models
end
|
Instance Method Details
#camelize(action_name) ⇒ Object
437
438
439
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 437
def camelize(action_name)
action_name.split('_').map(&:capitalize).join('')
end
|
#clazz_name(action_name) ⇒ Object
441
442
443
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 441
def clazz_name(action_name)
"Etna::Clients::Magma::#{camelize(action_name)}ActionValidator"
end
|
#project_model_names ⇒ Object
419
420
421
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 419
def project_model_names
project_models.all.map(&:template).map(&:name)
end
|
#validate ⇒ Object
423
424
425
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 423
def validate
validate_actions
end
|
#validate_actions ⇒ Object
427
428
429
430
431
432
433
434
435
|
# File 'lib/etna/clients/magma/workflows/json_validators.rb', line 427
def validate_actions
actions.each do |action|
clazz = Object.const_get(clazz_name(action.action_name))
validator = clazz.new(action, project_models)
validator.validate
@errors += validator.errors unless validator.valid?
end
end
|