Unregister an extension during runtime?

2 views
Skip to first unread message

Trevor

unread,
Nov 4, 2009, 3:47:45 PM11/4/09
to sinatrarb
My application registers extensions at runtime by doing a "require
'myextension.rb'" depending on the user's input. This registers a
couple of new routes for the extension. Is there a way to unregister
an extension during runtime which would delete it's routes?


require 'sinatra/base'

module Sinatra

module MyExtension

def self.registered(app)

app.get "/myextension" do
"hello from myextension"
end

end

end

register MyExtension

end

Nicolás Sanguinetti

unread,
Nov 4, 2009, 3:57:20 PM11/4/09
to sina...@googlegroups.com
On Wed, Nov 4, 2009 at 6:47 PM, Trevor <trevo...@gmail.com> wrote:
>
> My application registers extensions at runtime by doing a "require
> 'myextension.rb'" depending on the user's input. This registers a
> couple of new routes for the extension. Is there a way to unregister
> an extension during runtime which would delete it's routes?

No, you can't do that. (Not like that, you could modify the internal
state of the app which holds the routes, but you'll have to do it
manually for each route added for the extension.)

In any case, why would you do that? Something sounds horribly wrong :)

-foca

Bob Aman

unread,
Nov 4, 2009, 10:07:55 PM11/4/09
to sina...@googlegroups.com
> In any case, why would you do that? Something sounds horribly wrong :)

Yeah... PHP programmers do this sort of thing and it typically gets
them in deep, deep trouble security-wise.

-Bob Aman

Reply all
Reply to author
Forward
0 new messages