The protected write_attribute method of SparkApi::Models::Base checks whether the value being set for an attribute is already set to the assigned value. This causes inconsistent behavior when the attribute is new and the assigned value is nil because attributes is a hash and returns nil when a key does not exist.
This can be partially worked around by writing to the attributes hash directly. However, as illustrated above, that isn't a full-featured approach with respect to the SparkApi::Models::Dirty module at least.
On second thought, l.changes isn't a great example of the workaround not being full-featured. However, the general point remains that this is inconsistent behavior.
The protected
write_attribute
method ofSparkApi::Models::Base
checks whether the value being set for an attribute is already set to the assigned value. This causes inconsistent behavior when the attribute is new and the assigned value isnil
becauseattributes
is a hash and returnsnil
when a key does not exist.This can be partially worked around by writing to the
attributes
hash directly. However, as illustrated above, that isn't a full-featured approach with respect to theSparkApi::Models::Dirty
module at least.On second thought,
l.changes
isn't a great example of the workaround not being full-featured. However, the general point remains that this is inconsistent behavior.