By defining a struct one guarantees that the instances’ keys are exactly those provided in the definition. By including a key within the enforce_keys
attribute one ensures that the corresponding values cannot be nil
.
In my view, the attribute name enforce_keys
suggests that the keys listed there will be always present in the struct (which is actually the case for all keys provided in the definition) rather than that the corresponding values cannot be nil.