13 Jan 2009, 10:01am
/dev/ruby
by chris

4 comments

Method_missing requires responds_to?

I believe this should be taken as dogma and followed religiously:

I reject the argument because I reject as buggy any code such that object o responds to method m but o.responds_to?(:m) => false. If you implement your own method_missing for a class, you should almost always implement your own responds_to? as well.

- Maybe

There is wisdom in them there words. Monkey-patching is (perhaps) ok, but voodoo should probably be avoided at all costs and an object that can act but won’t provide a means of letting you know without actually trying it is just plain ol’ voodoo. And programming voodoo is bad juju.