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
Singletoncode (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 theinstancemethod 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?