title: Detect which method called the routing condition in Sinatra
body: <p>I'm using Sinatra with namespace.
  When I tried to use condition, I met a problem.</p>
  
  <p>Here's the snippet of code</p>
  
  <pre><code>class MainApp &lt; Sinatra::Base
    register Sinatra::Namespace
    set(:role) do |role|
      condition{
        ### DETECT WHERE THIS IS CALLED
        p role
        true
      }
    end
  
    namespace '/api', :role =&gt; :admin do
      before do
        p "before"
      end
      get '/hoo' do
        p "hoo"
      end
    end
  
    namespace '/api' do
      get '/bar' do
        p "bar"
      end
    end
  end
  </code></pre>
  
  <p>The above code outputs following message to console when accessing <code>/api/hoo</code></p>
  
  <pre><code>:admin
  :admin
  "before"
  :admin
  "hoo"
  </code></pre>
  
  <p>I could not understand why <code>:admin</code> is displayed three times. However, maybe one is from <code>namespace</code>, and other twos are from <code>before</code> and <code>get '/hoo'</code>.</p>
  
  <p>On the other hand, accessing <code>/api/bar</code> shows <code>:admin</code> two times.</p>
  
  <p>I just want to do the filtering only before <code>get '/hoo'</code>. Is there any idea?</p>
  
  <p>NOTE: I don't wan't to change URL from <code>/api/hoo</code> to something like <code>/api/baz/hoo</code></p>