title: What is the relationship between a ruby class and module with the same name?
body: <p>In my rails app I have a <strong>models/foo.rb</strong> and <strong>models/foo/exceptions.rb</strong>:</p>
  
  <pre><code>class Foo
    include Foo::Exceptions
  end
  
  module Foo::Exceptions
    class MySpecialException &lt; Exception
    end
  end
  </code></pre>
  
  <p>At the rails console, I then see this:</p>
  
  <pre><code>&gt;&gt; Foo::MySpecialException
  Foo::Exceptions::MySpecialException &lt; Exception
  &gt;&gt; Foo::MySpecialException == Foo::Exceptions::MySpecialException
  true
  &gt;&gt; Foo::MySpecialException === Foo::Exceptions::MySpecialException
  false
  </code></pre>
  
  <ol>
  <li>What do you think of my file structure / namespacing?</li>
  <li>Is my inclusion line in <code>Foo</code> necessary, or does Rails autoinclude those modules?</li>
  <li>Why does <code>MySpecialException</code> exist in the top level <code>Foo</code> namespace and point to <code>Foo::Exceptions::MySpecialException</code>?</li>
  <li>What does it mean that those two classes are <code>==</code> but not <code>===</code>?</li>
  </ol>
  
  <p>I explored this in irb but kept running into errors that were inconsistent with the behavior I (think) I've seen in Rails.</p>
  
  <p>related: <a href="https://stackoverflow.com/questions/4829788/what-is-a-good-place-to-keep-custom-exception-definitions-in-a-rails-project">What is a conventional place to keep custom Exception definitions in a rails project?</a></p>