vanruby/canada — pull request #4 by DaveTD (2013-10-26 02:50:06+00:00)
Title: adding functionality/testing for eh

Hello from Ottawa! Sorry to bother you guys, but I was looking at your gem and after looking at issue #2, I realized that there were a couple of problems people had with the "eh?" functionality in the gem. Luckily, ruby standards resolve one of those issues, so we can all be happy Canadians!

Ruby's naming conventions for mutation procedures is borrowed from scheme (section 1.3.5: http://www.schemers.org/Documents/Standards/R5RS/HTML/). What they're describing is similar to what somebody was mentioning when they said that the "eh" method should seek to accommodate the user's request. As such, I've created some extra functionality which implements an "eh!" method, for which Canadian made classes can seek said accommodations.

It would be expected of Canadian classes to include eh_{method name} methods for commonly used methods which could return undesired results. This method should contain instructions for how to accommodate the calling object's request, even in a situation where the Canadian object would usually return something the object wouldn't want. This abstracts needing to know all of the methods involved in making a commonly desired method return commonly desired results.

In the test example, we have a Tim Hortons (which I understand is a bit bigger here out east than it is in Vancouver, but let's be inclusive here) which doesn't have maple doughnuts ready. Calling the "doughnutAvailable_eh!" method causes a batch of maple doughnuts to be baked, to accommodate the maple doughnut request.

In the future, a more verbose example should be used where we should probably have more than just a "bake" method call in the eh_doughnutAvailable method in the Tim Hortons class - maybe a "glaze" method that takes a thickness int for the glaze, or a "fillDoughnut" method that takes a volume of maple cream to be piped into it. That way, we can have extra instructions for how to make maple doughnuts which the requesting class no longer needs to know about. After all, I don't know how to make maple doughnuts, but that shouldn't stop me from being able to ask for them to be made for me.

The changes also include an error for when "_eh!" is called on a non-Canadian class. It will tell you that the class probably isn't from around here.

If any of you guys are even in Ottawa on a Tuesday night, check out http://ottawaruby.ca/ to see if we have an event going on!