Commit 55c7155
committed
Deprecate writing to
The Base class defines an `attr_accessor :attributes` that is marked
with `# :nodoc:`. Technically, this means that any interaction with
`Base#attributes` or `Base#attributes=` is not part of the public
interface, 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#attributes` method.
The migration to `ActiveModel::Attributes` proposed in [rails#410][] will
involve changes to the `Base#attributes` method (due to
[ActiveModel::Attributes#attributes][]). Reading from the value returned
by `ActiveModel::Attributes#attributes` will remain the same, but
writing 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::Attributes` does not expose a corresponding
`#attributes=` method. By deprecating `#attributes=`, changes made that
incorporate `ActiveModel::Attributes` will not need to add an otherwise
unnecessary `#attributes=` implementation.
Once deprecated and part of a release cycle, the
`ActiveResource::AttributeSet` class can be removed, and the Active
Model migration's backwards compatibility burden can be reduced.
[rails#410]: rails#410
[ActiveModel::Attributes#attributes]: https://edgeapi.rubyonrails.org/classes/ActiveModel/Attributes.html#method-i-attributes
[ActiveModel::AttributeSet#to_hash]: https://github.com/rails/rails/blob/v8.1.1/activemodel/lib/active_model/attribute_set.rb#L36-L39Base#attributes
1 parent e577c6d commit 55c7155
File tree
4 files changed
+59
-4
lines changed- lib
- active_resource
- test/cases
4 files changed
+59
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1276 | 1276 | | |
1277 | 1277 | | |
1278 | 1278 | | |
1279 | | - | |
1280 | 1279 | | |
1281 | 1280 | | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
1282 | 1290 | | |
1283 | 1291 | | |
1284 | 1292 | | |
| |||
1385 | 1393 | | |
1386 | 1394 | | |
1387 | 1395 | | |
1388 | | - | |
| 1396 | + | |
1389 | 1397 | | |
1390 | 1398 | | |
1391 | 1399 | | |
| |||
1439 | 1447 | | |
1440 | 1448 | | |
1441 | 1449 | | |
1442 | | - | |
| 1450 | + | |
1443 | 1451 | | |
1444 | 1452 | | |
1445 | 1453 | | |
| |||
1842 | 1850 | | |
1843 | 1851 | | |
1844 | 1852 | | |
1845 | | - | |
| 1853 | + | |
1846 | 1854 | | |
1847 | 1855 | | |
1848 | 1856 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1743 | 1743 | | |
1744 | 1744 | | |
1745 | 1745 | | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
1746 | 1780 | | |
0 commit comments