Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:44:03+00:00 2026-05-28T14:44:03+00:00

I want figure out the connection between the Rack and Sinatra, so I dig

  • 0

I want figure out the connection between the Rack and Sinatra, so I dig into the source code, then I found the the definition of the basic class method get:

def get(path, opts={}, &block)
  conditions = @conditions.dup
  route('GET', path, opts, &block)

  @conditions = conditions
  route('HEAD', path, opts, &block)
end

now what’s the method: route? I’m currently using yard document tool, I just can’t find the definition of route in any Sinatra code or even Rack code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:44:04+00:00Added an answer on May 28, 2026 at 2:44 pm

    You didn’t look for the source code very well 🙂 10 lines below #get method definition there is a definition of route private method:

    # lib/sinatra/base.rb, line 1212
    private
          def route(verb, path, options={}, &block)
            # Because of self.options.host
            host_name(options.delete(:host)) if options.key?(:host)
            enable :empty_path_info if path == "" and empty_path_info.nil?
            signature = compile!(verb, path, block, options)
            (@routes[verb] ||= []) << signature
            invoke_hook(:route_added, verb, path, block)
            signature
          end
    

    This is a private method and you will not find it in the Sinatra documentation.

    Generally this method does the following: It create proc from passed &block, combine it with http path, keys and invocation conditions (inside compile! method) and store it in @routes[verb] class instance variable so that block may be found by path and conditions and executed later on (this class also has attr_reader :routes defined so that other classes may get acces to its @routes instance variable).

    Later when you get http request matching this route (@request instance variable of Base class ) the block is executed inside Base#route! method (see line 795).

    I would recommend you to use some IDE that help to examin source code. For example I use Rubymine for this purpose and its feature Go To -> Declaration: Just put your cursor on the variable/method/class/etc, press F12 and Rubymine will find it for you, even in source code of connected gems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do something but cant figure out how to do this (i
I'm trying to figure out if I can get what I want out of
I want to format a datetime field but i can't figure out the syntactic.
I'm trying to figure out Afterthought. I want to set the variable HasChanged when
I'm trying to figure out how to use Zend_Db_Table_Abstract correctly. I want to return
I'm trying to figure out Elisp, and I've hit a roadblock. I want a
Is it somehow possible, to figure out client PC CPU capabilities? I want my
Total newbie question, but I cant figure out what im doing wrong. I want
I know what I want to do but I can't quite figure it out.
I want to count payment within selected date, but i can't figure it out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.