title: Ruby, Sinatra, Overriding/Extending a class from a separate file to add a method
body: <p>I'm new to Ruby, I can find answers for various variations on this question but not an answer to my problem itself.</p>
  
  <p>I am writing an application which takes basic auth details and uses them to authenticate the user with a 3rd party platform as such I need to be able to access the password in order to pass it on <strong>but</strong> I also want to be able to use the Rack Authentication classes</p>
  
  <p>All I want to do is this:</p>
  
  <pre><code>require 'rack/auth/abstract/request'
  require 'rack/auth/basic'
  
  class AuthRequest &lt; Rack::Auth::Basic::Request &lt; Rack::Auth::AbstractRequest
      def password
        credentials[1]
      end
  end
  </code></pre>
  
  <p>If I use <code>Request &lt; Auth::AbstractRequest</code> the IDE tells me I have undeclare constant, but if I fully qualify it as above it says 'wrong argument type true (expected Class) (TypeError)'</p>
  
  <p>I read various articles including <a href="http://tech.tulentsev.com/2012/02/ruby-how-to-override-class-method-with-a-module/" rel="nofollow">this</a> but I'm no less confused, I think the problem stems from the fact I'm trying to extend a subclass from this external file, not it's root class.</p>
  
  <p>What's the right way to do this?</p>
  
  <p><strong>Edit</strong> - some more information on my requirement:
  I'm basing this need on this sample from the Sinatra documentation. I want the <code>@auth</code> object for the niceness like <code>provided?</code> and <code>basic?</code> but as I can't simply do a comparison like <code>@auth.credentials == ['admin', 'admin']</code>, I need access to the password, which is not granted in the default implementation</p>
  
  <pre><code>helpers do 
  
    ...
  
    def authorized?
      @auth ||=  Rack::Auth::Basic::Request.new(request.env)
      @auth.provided? &amp;&amp; @auth.basic? &amp;&amp; @auth.credentials &amp;&amp; @auth.credentials == ['admin', 'admin']
    end
  
  end
  </code></pre>