GuessMethod 0.1.2
I’m starting to see a pattern. I make one change to GuessMethod, release it, then think of something else almost immediately and release again. And such brings us to 0.1.2.
I almost called this one 0.2 because I think I finally figured out how GuessMethod should really work, which is this way:
- Call the original method_missing or const_missing and let it go through unless…
- it raises a NameError or NoMethodError, in which case…
- capture the error and…
- try to guess.
If the guess is successful, apply the guess. If not, raise the original error.
Now this all seems so obvious. But so much is in hindsight.
Anyway, don’t let anyone try to trick you into thinking this is somehow something to be used in production, or even outside of irb. This doesn’t belong anywhere except in irb.
I’ve been trying to think of how to put this in your .irbrc so that things go the best way possible. I think this is it:
require 'guessmethod' if defined?(IRB) and not ENV.has_key?('RAILS_ENV')
Go get it. I swear I wouldn’t work on this unless it made irb more fun, which it totally does.