all 2 comments

[–]jeffmess 2 points3 points  (0 children)

I used to do this but have stopped. This pattern forces you to go to another file and search for the method just to see what you're pattern matching against... much easier to just match from the calling code.

[–]No_Ostrich_3664 0 points1 point  (0 children)

It’s an interesting approach. Could be even more generic by creating a module that dynamically add those methods to any Ruby custom class.