title: Declarative ruby programming replacement for if/then/else/RETURN/end?
body: <p>I have this showing up all over in my controllers:</p>
  
  <pre><code>if not session[:admin]
    flash[:notice] = "You don't have the rights to do #{:action}."
    redirect_to :action=&gt;:index
    return
  end
  </code></pre>
  
  <p>And its sibling:</p>
  
  <pre><code>if not session[:user] and not session[:admin]
    flash[:notice] = "You don't have the rights to do #{:action}."
    redirect_to :action=&gt;:index
    return
  end
  </code></pre>
  
  <p>I would like to reduce this all down to a single declarative line when I want to use it in a method:</p>
  
  <pre><code>def action_which_requires_rights
      require_rights :admin
      #or:
      #:require_rights :user_or_admin
  end
  </code></pre>
  
  <p>Clearly, if require_rights fails, I don't want the rest of the method executed.  I would swear that there was a way to do this, but I can't find where I read about it.  Am I imagining this?</p>