Module: PgVerify::Model::Validation::ForeignAssignmentValidation

Defined in:
lib/pg-verify/model/validation/foreign_assignment_validation.rb

Class Method Summary collapse

Class Method Details

.validate(model) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pg-verify/model/validation/foreign_assignment_validation.rb', line 7

def self.validate(model)
    errors = []
    varset = model.all_variables()

    model.components.each { |component|
        actions = component.transitions.map(&:action).compact
        actions.each { |a|
            var_strings = a.assigned_variables()
            # Null values (variable not known is not an error for this validation)
            vars = var_strings.map { |vs| varset[vs] }.compact
            vars.map { |var|
                next if var.owner_name == component.name
                errors << ForeignVariableAssignmentError.new(var.name, a, varset, component)
            }
        }
    }
    return errors
end