Marcel Molina, Jr. has a real talent for discovering elegant API’s. It’s been a treat working with him this last year, watching how he spends a little extra time on the developer interface to the unit tests or a library, making it nice and clean. I wish you could see what he and Sam did with the tests for Campfire!
In a recent post to the Projectionist tumblelog, Marcel provides a tip for avoid[ing] cluttering built in classes by using just in time convenience methods. I love it! His focus is specifically on the instance_eval in the find_items_matching method, but I love the whole snippet. Take a string, extend it with some methods, and voila! A mini-API for querying that string. So much cleaner than just chaining a bunch of grep and match calls together. His instance_eval trick really just adds another mini-API to the array that is returned. API’s within API’s! Neat stuff.