-
Notifications
You must be signed in to change notification settings - Fork 21.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Active Model Dirty API. #16180
Conversation
…_information This method name is causing confusion with the `reset_#{attribute}` methods. While `reset_name` set the value of the name attribute for the previous value the `reset_changes` only discard the changes and previous changes.
|
@@ -215,6 +224,16 @@ def attribute_will_change!(attr) | |||
|
|||
# Handle <tt>reset_*!</tt> for +method_missing+. | |||
def reset_attribute!(attr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def restore_attribute!(attr)
? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm 🙈
|
❤️ 💚 💙 💛 💜 |
|
How about As a bonus, it could take a list of attributes for when you want to restrict it to just a subset of possibly-changed-or-not attributes (e.g. Not sure if "attributes" is what you call them in the Active Model layer though. |
(or |
I like |
These methods may cause confusion with the `reset_changes` that behaves differently of them. Also rename undo_changes to restore_changes to match this new set of methods.
Changed to |
❤️ |
Improve Active Model Dirty API.
good job |
I did some changes on this API:
reset_changes
becomesclear_changes_information
. I believe this new name matches with what it is doing.reset_*
is deprecated in favor ofrestore_*
. This will avoid confusion with the deprecated reset_changes.undo_changes
is nowrestore_attributes
. To match the behaviour ofrestore_*
.@dhh @chancancode