Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

If the intent of Active Resource to be similar enough to Active Record for its users to be able to intuit its interfaces, the absence of Base#update can is a surprise.

Prior to this commit, the was an existent Base#update protected method that handles issuing the PUT request. Its interface is more akin to Base#save, in that it did not accept attributes.

This commit foists that method from being protected to be public. It changes the interface to accept attributes. It retains the original implementation when the attributes argument is omitted (for the sake of backwards compatibility). When attributes are provided, forward them to the Base#update_attributes method. Explicitly document the interface that indicates that the only way for public callers to invoke the method if with an attributes argument.

This commit also implements the Base#update_attribute method in terms of the Base#update_attributes method.

If the intent of Active Resource to be similar enough to Active Record
for its users to be able to intuit its interfaces, the absence of
`Base#update` can is a surprise.

Prior to this commit, the was an existent `Base#update` protected method
that handles issuing the `PUT` request. Its interface is more akin to
`Base#save`, in that it did not accept attributes.

This commit foists that method from being `protected` to be `public`. It
changes the interface to accept attributes. It retains the original
implementation when the `attributes` argument is omitted (for the sake
of backwards compatibility). When `attributes` are provided, forward
them to the `Base#update_attributes` method. Explicitly document the
interface that indicates that the only way for public callers to invoke
the method if with an `attributes` argument.

This commit also implements the `Base#update_attribute` method in terms
of the `Base#update_attributes` method.
@seanpdoyle seanpdoyle force-pushed the update-with-attributes branch from 04e8b59 to 51dfdb5 Compare October 24, 2025 18:53
@rafaelfranca rafaelfranca merged commit 7b4b2b0 into rails:main Oct 24, 2025
19 checks passed
@seanpdoyle seanpdoyle deleted the update-with-attributes branch October 24, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants