Own-and-Ship / oas_agent

The Own & Ship Ruby agent
2 stars 0 forks source link

Monkey-patch responsibly #7

Closed caius closed 1 year ago

caius commented 1 year ago

What?

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

wjessop commented 1 year ago

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.