Skip to: Site menu | Main content

Archive for March, 2008

Cute method_missing hack

I love abusing method_missing in Ruby, it is great fun.
 module IsDoesIsntDoesnt

def method_missing(method, *args)
m = method.to_s
if (m =~ /^is_(\w*?\?)$/) || (m =~ /^does_(\w*?\?)$/)
real_method = $1.to_sym
return send(real_method, *args) if respond_to?(real_method)
elsif (m [...]