Recently my team and I started using ruby 2.1.1 in production on www.musicxray.com. With this change we now have the ability to use the prepend method inside of our classes. The prepend functionality allows a fairly clean syntax for wrapping existing functionality in custom code in a dynamic way.
The difference is how prepend influences the object hierarchy in ruby. While include adds a object further up the object hierarchy, prepend allows you to put your code in front of the object hierarchy. This means that when you call super from your module you are calling the method on the class that prepended the the modele.
This is a very simple example but I think it illustrates some powerful concepts. What we are trying to do is give ourselves a module that when mixed in allows us to list the methods we would like to silence errors on. We could use this functionality to automatically log errors to the log instead of breaking a user interface for our users in a rails application. Here is the example I came up with.
I find this method of method wrapping much cleaner than using method alias, what do you think?