Reputation: 692
When reading the Sinatra docs I got the impression that all the routes and helpers just go into a single file. However, after reading a lot of the Sinatra questions and answers here on Stack, I see that most people are placing their routes and helper in a class. What benefits does this provide over a collection a blocks?
Edit: I get that putting router and helpers in their own modules is helpful but why should I have a class for the application?
Upvotes: 1
Views: 205
Reputation: 35783
Organization and reducing namespace pollution. When all my handlers are in the module Handlers
, it's very clear what they all are, I can manipulate them as a group (iterate, redefine, etc.). Also, it reduces global namespace pollution by putting things in their own namespace.
Upvotes: 3