From: Paul Novak Date: 2007-05-03T10:50:04+09:00 Subject: Re: Checking Credit Cards (#122) Thank you James for another fun quiz. My solution is a more verbose version of the metaprogramming-based routing used in why's excellent camping. But instead of regexen matching urls to controller classes, here they are matching card numbers to the card classes. What I like about this approach is that you can add more card patterns just by adding more classes with the appropriate regexen, and you can override validation or other functionality as needed. Regards, Paul. # cardvalidator.rb # require 'metaid' module Card @cards=[] def Card.Base *u c = @cards Class.new { meta_def(:patterns){u} meta_def(:validity){|x|Card.validity(x)} meta_def(:inherited){|x|c<