Closed caius closed 1 year ago
Warning
Module#prepend
Module#extend
Modern[^1] rubies require modern methods of patching to play nicely with other gems that may also patch the same behaviour. https://blog.appsignal.com/2021/08/24/responsible-monkeypatching-in-ruby.html#monkeypatching-responsibly has a bunch more context around the change.
Also improve the testability of the injection code by allowing dependency-injection of the Warning constant so we can inject a different module under test.
This will currently break Ruby < 2.0 as Module#prepend didn't exist there.
[^1]: Ruby 2.0 and higher
This is probably going to have to wait, if do manage to get earlier versions of Ruby working then this isn't going to work.
What?
Warning
usingModule#prepend
rather thanModule#extend
Why?
Modern[^1] rubies require modern methods of patching to play nicely with other gems that may also patch the same behaviour. https://blog.appsignal.com/2021/08/24/responsible-monkeypatching-in-ruby.html#monkeypatching-responsibly has a bunch more context around the change.
Also improve the testability of the injection code by allowing dependency-injection of the
Warning
constant so we can inject a different module under test.This will currently break Ruby < 2.0 as Module#prepend didn't exist there.
[^1]: Ruby 2.0 and higher