Own-and-Ship / oas_agent

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

Modern Monkey-Patching in Modern Ruby #17

Open caius opened 10 months ago

caius commented 10 months ago

What?

Why?

Modern[^1] rubies allow more 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 and background around why this is compared to what we used to do.

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.

We still need to function on Ruby 1.9, so will have to maintain a split in injection based on ruby version.

[^1]: Ruby 2.0 and higher