Kenneth  wrote:
> Hi, the point I was trying to make was sending a boolean method to the 
> case.

Then no, there is not a variant of the case statement which does this.

> I was hoping there would be something like
> case user
> when banned?    then ...
> when activated? then ...
> end

If you want to invoke method 'banned?' on a particular object, then you 
have to send it to that object. A bare called to 'banned?' is invoked on 
the current object (self).

But here are a couple of alternatives to consider:

user = Object.new
def user.banned?; false; end
def user.activated?; true; end

# Example 1

user.instance_eval {
  case
  when banned?;    puts "Banned!"
  when activated?; puts "Activated!"
  end
}

# Example 2

[
  [:banned?, lambda { puts "Banned!" }],
  [:activated?, lambda { puts "Activated!" }],
].each do |method, action|
  user.send(method) && (action[]; break)
end

However if it's only a handful of conditions I'd be inclined to write

when user.banned?
when user.activated?
-- 
Posted via http://www.ruby-forum.com/.