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
Style/MethodMissing fallback on super doesn't make sense when you are responding to everything #3760
Comments
I have the same problem. In a presenter library, we use method missing to send private method calls to the view context: private
# Delegates private method calls to the view context
def method_missing(method, *args, &block)
context.public_send(method, *args, &block)
end I get the message “When using method_missing, fall back on super”, but calling cc/ @Drenmi |
There are actually two intimately connected parts to this:
The first one is pretty error prone to check for though, because of the different ways this can be done. I can see how this is totally confusing when It is probably possible to detect when
WDYT? |
So my example from above should be changed to: def method_missing(method, *args, &block)
if context.respond_to?(method)
context.public_send(method, *args, &block)
else
super
end
end Yeah, that makes sense. Changing the violation message may be the way to go. |
This still doesn't make sense with certain helper object patters like a black-hole NullObject:
|
Any updates on this? I have a class, which delegates method calls to another classes... I believe class API
def method_missing(method_name, *arguments, &block)
client.send(method_name, *aguments, &block)
end
private
def client
if Config.fake_client?
FakeHTTPClient
else
RealHTTPClient
end
end
end Maybe we should drop check for |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it. |
Great solution @bquorning This is what I was looking for: def method_missing(method, *args, &block)
if context.respond_to?(method)
context.public_send(method, *args, &block)
else
super
end
end |
The
super
is unreachable, althoughStyle/MethodMissing
demands itThe text was updated successfully, but these errors were encountered: