Exceptions vs method missing in Ruby and Rails
- May 19th, 2010
- Write comment
After some looking around here is what i found and thought others would find useful as well
Exceptions in general are really slow in ruby and should be thought of as exceptional. method_missing is not an exception but is actually a kernel method of ruby. When you invoke a method on ruby the runtime will search the entire class and module heirarchhy all the way to object, class and module and then as a last case call method_missing. Its more like it just calls this method and you can override this method at anypoint in the chain. Its definitely slower than calling a method that does exist because it has to search up the heirarchy but it is definitely faster than exceptions.
Here are some other posts that i found useful during my review of this area: