1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 def check_update_whitelist permitted_fields
7 attribute_names.each do |field|
8 if !permitted_fields.include?(field.to_sym) && really_changed(field)
9 errors.add field, "cannot be modified in state '#{self.state}' (#{send(field+"_was").inspect}, #{send(field).inspect})"
14 def really_changed(attr)
15 return false if !send(attr+"_changed?")
16 old = send(attr+"_was")
18 if (old.nil? || old == [] || old == {}) && (new.nil? || new == [] || new == {})
25 def validate_state_change
26 if self.state_changed?
27 unless state_transitions[self.state_was].andand.include? self.state
28 errors.add :state, "cannot change from #{self.state_was} to #{self.state}"