Ruby Method Autoload

Continuing to study Rails’ source, I quickly had to take a look at the Rack gem, which wraps HTTP requests and responses. It’s far smaller than Rails.

The first thing that caught my attention was the way it loads the modules.

autoload :Builder, "rack/builder"

Autoload is Ruby’s way to lazy load modules. It only loads the above module when Builder is called in the code. This page breaks it down in more detail.

Comments