-
Notifications
You must be signed in to change notification settings - Fork 87
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
Fix fallthrough accessor method_missing not passing all options to super #364
Conversation
Oh and just one more idea (not yet fully tested and not thought to the end): It might be possible to speed up fallthrough accessor by defining an instance method inside define_method :method_missing do |method_name, *arguments, **options, &block|
if method_name =~ method_name_regex
attribute = $1.to_sym
locale, suffix = $2.split('_')
locale = "#{locale}-#{suffix.upcase}" if suffix
singleton_class.define_method(method_name) do |*arguments, **options|
public_send("#{attribute}#{$4}", *arguments, **options, locale: locale.to_sym)
end
public_send(method_name, *arguments, **options)
else
super(method_name, *arguments, **options, &block)
end
end This way One has to think about how the method is defined exactly (especially the arguments), but this could be a way to speed up fallthrough accessors which will then have only a penalty on first call. Though this is something for another PR. |
@shioyama maybe you can find some time to look at this? It is a fairly small change that unbreaks my App. |
Sorry I will try to get to this and other issues in the next week or two.
…On March 27, 2020 10:20:34 PM GMT+09:00, Markus ***@***.***> wrote:
@shioyama maybe you can find some time to look at this? It is a fairly
small change that unbreaks my App.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#364 (comment)
|
Sorry for the delay! Thanks for the change, it looks great 👍 Do you think you could add a test so we avoid any future regression? |
Never mind I added a spec in abd67a2. If specs pass I'll merge & release 🙂 |
Thanks! |
It's passing 🎉 I'll merge it and deploy later tonight, thanks for catching this! |
Released in 0.8.12 🎉 |
When mobility handled something it wasn't responsible for, it didn't pass all options to
super
and actually swallowedoptions
. Other method missing handlers couldn't work as intended then.