Deprecate writing to Base#attributes
#463
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Base class defines an
attr_accessor :attributesthat is markedwith
# :nodoc:. Technically, this means that any interaction withBase#attributesorBase#attributes=is not part of the publicinterface, and is free to be changed or removed without breaking the
public API.
However, given the project's age and the long-term period of time with
minimal changes to the public interface, this PR proposes that there be
a public deprecation of writing to the Hash instance returned by the
Base#attributesmethod.The migration to
ActiveModel::Attributesproposed in #410 willinvolve changes to the
Base#attributesmethod (due toActiveModel::Attributes#attributes). Reading from the value returned
by
ActiveModel::Attributes#attributeswill remain the same, butwriting to that value will have no affect since the value is a Hash copy
created by ActiveModel::AttributeSet#to_hash, and not the Hash
instance used internally.
Similarly,
ActiveModel::Attributesdoes not expose a corresponding#attributes=method. By deprecating#attributes=, changes made thatincorporate
ActiveModel::Attributeswill not need to add an otherwiseunnecessary
#attributes=implementation.Once deprecated and part of a release cycle, the
ActiveResource::AttributeSetclass can be removed, and the ActiveModel migration's backwards compatibility burden can be reduced.