You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Taxjar::Base and all the data models that currently inherit from it use a confusing mix of data states, stored both directly into an @attrs instance variable, and also managed by ModelAttributes (which stores each attribute in its own instance variable).
While these states are initially in-sync when the object is constructed, using any of the attribute writers causes these states to go out of sync, and data read from the attributes to no longer match the data to be sent in an API request.
Taxjar::Base
and all the data models that currently inherit from it use a confusing mix of data states, stored both directly into an@attrs
instance variable, and also managed byModelAttributes
(which stores each attribute in its own instance variable).While these states are initially in-sync when the object is constructed, using any of the attribute writers causes these states to go out of sync, and data read from the attributes to no longer match the data to be sent in an API request.
Expected Behaviour
Actual Behaviour
This is caused because
Taxjar::Base
stores two separate data states:@attrs
, which is only assigned in the constructor, and delegates#to_hash
ModelAttributes
, which is initialized in the constructor, and whenever attribute writers are used, but never updates@attrs
stateAnother Example
This happens because
Taxjar::Base#to_h
andTaxjar::Base#to_hash
delegate to@attrs
, which is not updated by attribute writers.Suggested Fix
All usage of
@attrs
should be removed, instead using the#attributes
method provided byModelAttributes
.The text was updated successfully, but these errors were encountered: