First, we shim the Ruby Object class with a profiling aspect, in this case an additional method called profile that will wrap any existing method with timing code that we tell it to. Lets put this in a file called: aop_extension.rb. class Object def Object.profile symbol _symbol = ("rprof_" + symbol.to_s).to_sym alias_method _symbol, symbol # Define the new wrapper method self.send(:define_method,
![Ruby AOP in 12 lines of Code](https://cdn-ak-scissors.b.st-hatena.com/image/square/8d71ff5111e05619a10d29bb40d7aebaa75c8fbc/height=288;version=1;width=512/https%3A%2F%2Fs0.wp.com%2Fi%2Fblank.jpg)