Test for the new exception of delegate_missing_to #30191
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
Based on @matthewd's comment in the original PR, can you change the implementation to only check for nil if |
Done. I didn't go this way initially because the code turns out not pretty. Is there a better way to write it? |
end | ||
def delegation_error_if_target_nil(target, method) | ||
begin |
rafaelfranca
Aug 11, 2017
Member
You can remove the begin
here.
You can remove the begin
here.
end | ||
end | ||
def delegation_error_if_target_nil(target, method) |
rafaelfranca
Aug 11, 2017
Member
This method should be private, and starts with _
to avoid conflicts with the methods in the including class.
This method should be private, and starts with _
to avoid conflicts with the methods in the including class.
gsamokovarov
Aug 11, 2017
Contributor
Should we extract the method at all, we're still monkey patching a core object here. Any pollution counts.
Should we extract the method at all, we're still monkey patching a core object here. Any pollution counts.
rafaelfranca
Aug 11, 2017
Member
Yeah, I don't think it is necessary. begin/end
inside that else is good enough.
Yeah, I don't think it is necessary. begin/end
inside that else is good enough.
I think that is fine |
Is I'd say it isn't, because you can instead do delegate_missing_to :person_responsible
def person_responsible
president || chief || captain
end |
It is not, because only the last call is going to be used. |
I think we can go with the version without the private method just to avoid polluting the caller more |
This is amazing. Thank you for doing this. |
A follow-up to the change to delegate_missing_to made in #30084.