Over the summer of 2012, I started using Ruby more seriously and began to learn about its powerful meta-programming capabilities. This made Ruby an ideal language for the following 2 “hacks.” As a final disclaimer, I’d like to stress that I did these as a fun exercise only.
Fuzzy method invocationGO TO THE SOURCECODE
Oops overrides BasicObject’s method_missing function with spell-checking which attempts to find a closely matching method (by name and argument count) and executing it.
A hard reset for objectsGO TO THE SOURCECODE
Inspired by the following facebook status (Sam Bowman):
There needs to be a […] programming feature called the “smack it” function. This would be […] the equivalent of smacking an off kilter mechanical or electrical device.
Smackit works by overriding an object’s new method to store the arguments passed to it. On smacking an object, it creates a new object with the same initial arguments as the smacked object.