I have a Padrino project made of several applications and I want to write a module to avoid repeating this in every sub app:
class MySubApp < Padrino::Application
register Padrino::Rendering
register Padrino::Helpers
register Padrino::Warden
enable :sessions
before do
env['warden'].authenticate!
end
get '/debug' do
...
end
end
Instead I would like to write just this:
class MySubApp < Padrino::Application
include MyAppsExtension
end
I've been trying different things defining the repeated code within a module and also nested within the Sinatra module, but I still cannot get the right way to define this.
Also I tried making an intermediate class between my apps and Padrino::Application, but I get many errors and the Sinatra DSL functions (before/get...) are lost.
How can I write such extension?