If you can make MyAppsExtension
an extension then when it is registered the registered
method is called and passed the actual app. In this method you can set up your app how you’d like, including registering other extensions.
module MyAppExtension
def self.registered(app)
# use 'app' as you would use 'self' in your app
app.register Padrino::Rendering
app.register Padrino::Helpers
app.register Padrino::Warden
app.enable :sessions
app.before do
env['warden'].authenticate!
end
app.get '/debug' do
...
end
end
end
You can then use this like you would any other extension:
class MySubApp < Padrino::Application
# 'register', not 'include'
register MyAppsExtension
end
Note that you don’t need to make your extension module a subclass of the Sinatra
module. Some extensions do, including those in the examples of the Sinatra docs. If you want to make your extensions available in classic style Sinatra apps (without needind to call register
) you would need to call Sinatra.register MyExtension
, but this isn’t necessary for modular apps.