Module: PgVerify::Model::Validation::AssignmentToStateVariableValidation

Defined in:
lib/pg-verify/model/validation/assignment_to_state_variable_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
# File 'lib/pg-verify/model/validation/assignment_to_state_variable_validation.rb', line 7

def self.validate(model)
    errors = []
    varset = model.all_variables()
    actions = model.components.map(&:transitions).flatten.map(&:action).compact
    actions.each { |action|
        action.assigned_variables().each { |var_string|
            var = varset[var_string]
            # Do not handle: Assignment to unknown variable
            next if var.nil?
            next unless var.state_variable?
            errors << AssignmentToStateVariableError.new(var.name, action, varset)
        }
    }
    return errors
end