Source: Love Your lib Directory By: Brian Cardarella
Far too often I’ve needed to extend a class that is being defined outside of my project. There are a few ways to deal with this. You can use a Composite to define a new class that you can then play around with. The downside to this is that I sometimes want to modify a class that is being inherited by other classes. This is when I think it is appropriate to Monkey Patch.
The pattern I have fallen upon is to define a gem_ext/ directory and a gem_ext.rb file in lib. I then make sure the extensions are loaded up using an initializer. For lack of a better term I call this lib_loader.rb. Lets start with the loader.
# config/initializers/lib_loader.rb
require 'gem_ext'