title: Ruby on Rails Case/Switch. How to match against object?
body: <p>I am working on a ruby on rails application. For a session controller, I want to use a case to check if a user's account is locked or banned. I am trying to use the object of a class as the case, and use when to check attributes.</p>
  
  <p>For example,</p>
  
  <pre><code>user = Profile.find(1)
  case user
  when user.ban
    redirect_to()
  when user.lock
    redirect_to()
  else
    redirect_to()
  end
  </code></pre>
  
  <p>The only problem is that doesn't work.</p>
  
  <p>What does work is this:</p>
  
  <pre><code>case user.ban
  when true
    redirect_to()
  else
    redirect_to()
  end
  </code></pre>
  
  <p>Any advice on how I can go about checking if a user object is banned or locked using a switch?</p>
  
  <p>Thank you</p>