title: How to make modular helper in Sinatra
body: <p>i want to make a method inside a module (for grouping reason) that can be called as a <code>module.method</code>, something like this:</p>
  
  <pre><code>helpers do
    module UserSession
      def logged_in?
        not session[:email].nil?
      end
      def logout!
        session[:email] = nil
      end
    end
  end
  </code></pre>
  
  <p>but when i try to call it using <code>UserSession.logged_in?</code> it said that logged_in is not UserSession's method</p>
  
  <blockquote>
    <p>undefined method `logged_in?' for UserSession:Module</p>
  </blockquote>
  
  <p>when i move the method as UserSession's method:</p>
  
  <pre><code>helpers do
    module UserSession
      def self.logged_in?
        not session[:email].nil? # error
      end
      def self.logout!
        session[:email] = nil
      end
    end
  end
  </code></pre>
  
  <p>it gives an error, that i could not access the <code>session</code> variable</p>
  
  <blockquote>
    <p>undefined local variable or method `session' for UserSession:Module</p>
  </blockquote>
  
  <p>what is the best solution for this problem?</p>