codereading / sinatra

Classy web-development dressed in a DSL (official / canonical repo)
http://www.sinatrarb.com/
MIT License
12 stars 2 forks source link

Why do sinatra/main requires sinatra/base? #12

Open agis opened 12 years ago

agis commented 12 years ago

I know that a Sinatra app can be built using the Classic or the Modular style, meaning that it will require sinatra for the former and sinatra/base for the latter.

But I was wondering, why does sinatra/main.rb requires sinatra/base?

This is certainly not needed when you're using the Classic or the Modular way, cause in each case this file is loaded either via sinatra.rb (classic) or directly (modular).

gwynforthewyn commented 12 years ago

I imagined that this was the case because a module is meant to take care of its own dependencies. In the case of Sinatra/main, that dependency is Sinatra/base. In the case of Sinatra.rb, those dependencies are both base and main.

There's no harm in having a double require: require's smart enough to recognise that a file has already been required and won't re-require.

That was my assumption, anyway!