From: Benoit Daloze Date: 2010-07-08T02:14:52+09:00 Subject: Re: Ruby switches On 7 July 2010 15:53, Kenneth wrote: > Hi, the point I was trying to make was sending a boolean method to the > case. > > Let's say I have a User object and it has instance methods banned? and > activated? They are either true or false. > > Instead of doing > case > when user.banned?    then ... > when user.activated? then ... > end > > I was hoping there would be something like > case user > when banned?    then ... > when activated? then ... > end > > I would like to see something like this but it seems hard to implement. Ah, and if you would absolutely respect the same syntax, it is possible without changing self (but certainly not a good practice) def method_missing(meth, *a, &b) lambda { |obj| obj.send(meth, *a, &b) } end case user when banned? puts "Banned !" when activated? puts "This is insane but you're fine!" end