-
Notifications
You must be signed in to change notification settings - Fork 8
simplify #7
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
simplify #7
Conversation
This looks good to me, can you considerate feedback of |
@ioquatix if I understand @jeremyevans's feedback around does that address your concern or is there another test case we should add? |
(ruby/singleton#7) Remove `__init__` and move logic to `included`.
This reverts commit 545b6b6. This change break Rails CI: https://bugs.ruby-lang.org/issues/19711
(ruby/singleton#7)" This reverts commit ruby/singleton@545b6b61a40d. This change break Rails CI: https://bugs.ruby-lang.org/issues/19711 ruby/singleton@911531d508
I reverted this change because this break Rails CI. |
@hsbt thanks. |
@dpep your change was reverted because it broke Rails. That means the behaviour of your implementation changed, and unfortunately it was not covered by a test in this repository. https://bugs.ruby-lang.org/issues/19711 It looks like Rails expects subclasses of a Singleton to be instantiatable. If you have time, can you investigate? |
whoops, sorry about that! see #9 for a retry with improved test coverage to guard against this corner case |
I was trying to understand the
Singleton
code (neat!) and saw a few ways we could simplify. If we rollSingleton.__init__
intoincluded
, it means we don't have to expose that helper method to the public and creates a single entry point (include Singleton
). We could also simplify theinstance
method to have only a single return statement, at the end. I also added some tests that helped me catch a regression during development.(ported from ruby/ruby#7890 and thanks to @jeremyevans and @ioquatix for taking a first pass!)
Would this help?