Lol, I love Amadan's answer. And if you really want a case statement, you should probably be doing what Zepplock said (though might consider symbols in place of strings), but based on your use case, you want a more if-statement based solution, like Salil's.
Anyway, thought I'd throw in and have some fun too ^_^
Here is a solution that will work with what you said, it creates objects that respond to === (what case statements use), then they invoke the method of interest (lock or ban) and return it. You should probably put them into some sort of config or initializer, or otherwise store the results after the first invocation, in order to save performance (your app only needs to create these objects one time)
user = Class.new do
def ban() true end
def lock() true end
end.new
def banned?
ban_checker = Object.new
def ban_checker.===(user) user.ban end
ban_checker
end
def locked?
lock_checker = Object.new
def lock_checker.===(user) user.lock end
lock_checker
end
case user
when banned?
puts 'banned'
when locked?
puts 'locked'
else
puts 'default'
end
Note: I'm not advocating this solution, because it is violates encapsulation. Banned should be defined and used on your user, but to make this work, it must be defined in the enclosing scope. I mostly bring this up for fun :)