Change Base#update to accept attributes#447
Merged
Merged
Conversation
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.
04e8b59 to
51dfdb5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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#updatecan is a surprise.Prior to this commit, the was an existent
Base#updateprotected method that handles issuing thePUTrequest. Its interface is more akin toBase#save, in that it did not accept attributes.This commit foists that method from being
protectedto bepublic. It changes the interface to accept attributes. It retains the original implementation when theattributesargument is omitted (for the sake of backwards compatibility). Whenattributesare provided, forward them to theBase#update_attributesmethod. Explicitly document the interface that indicates that the only way for public callers to invoke the method if with anattributesargument.This commit also implements the
Base#update_attributemethod in terms of theBase#update_attributesmethod.