-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Some refactor for association. #5722
Some refactor for association. #5722
Conversation
@kennyj: I noticed you redefined reset to take in an optional target, but I don't see where this method is used with a non-nil paramater |
@kevmoo kennyj@37cc758#L1R74 |
@kennyj DRY'ing and standardizing are great, but where is this method called with a non-nil param? The other code path that sets I'm trying to understand why we'd want a reset code path that sets |
@carlosantoniodasilva I think we should use the same method signature possibly (especially public api). I have another 2 plan. plan1: we add default_target method.
plan2: without considering the inheritance, we implement reset method separately. What do you think ? |
@carlosantoniodasilva : I'm w/ you on the call to super it association_collection. I'm trying to understand the new target param on |
@kenny plan 1 with def reset
super
@target = []
end @kevmoo the new param is required so you can achieve the same result as my example above with |
@carlosantoniodasilva sounds good :-) more simply. I'll update commits. Thank you for reviewing |
done :-) |
Love it. Is there an associated test case? |
cetrainly, we needed to add some testcases. |
This looks fine to me, but I'm not keen on the test. Does this fix any bug? If not, let's just not bother with the test; it's just refactoring. |
@jonleighton Thank you for reviewing. |
Ok, please squash the commits :) then I'll merge. |
* Remove unused association_class method. * Remove a unnecessary assignment. * Move @Updated to BelongsToAssociation that only reference this instance variable. * Reset @stale_state at the reset method. I think this place is right place.
@jonleighton |
Some refactor for association.
I'm tackling #5663.
And I think some coding problems are existed on associations (redundant / class hierarchy of methods...).
This PR fix some problems.
Please review it :)