Jon,

do the new Reloadable and Reloadable::Subclasses modules in edge rails (and I assume to be included in 1.1) help you?

Regards,
Trevor

--
Trevor Squires
http://somethinglearned.com



On 1-Mar-06, at 8:00 PM, Jon Tirsen wrote:

I'm working on the plugin for RBatis and a new little thing I'm toying
around with called ActiveMessaging (sorry, David I stole the name from
you from the TW AwayDay ;-)). Anyway, in both these applications I
want to be able to have reloadable classes that don't extend any of
the standard built in ones.

So, I don't mean to offend the Eminent Core Members by digging up
their little skeletons but this code in dispacher.rb is.... well,
let's settle with saying it's not very extendable:
    def reset_application!
      Controllers.clear!
      Dependencies.clear
      ActiveRecord::Base.reset_subclasses
      Dependencies.remove_subclasses_for(ActiveRecord::Base,
ActiveRecord::Observer, ActionController::Base)
      Dependencies.remove_subclasses_for(ActionMailer::Base) if
defined?(ActionMailer::Base)
    end

In ActiveMessaging I need to reset the application from a non-web
scenario. (I have a polling process that receive messages from a
messaging infrastructure and I want reloading to happen in between
messages.) So ideally I would like to keep this outside ActionPack
(ActionPack might not even be loaded for a lot of messaging
applications!).

So I was thinking maybe an ApplicationResetter that you could add
stuff to, like so:
in ActiveRecord:
ApplicationResetter.on_reset do
      ActiveRecord::Base.reset_subclasses
      Dependencies.remove_subclasses_for(ActiveRecord::Base)
end
in ActionPack:
ApplicationResetter.on_reset do
      Controllers.clear!
      ActiveRecord::Base.reset_subclasses
      Dependencies.remove_subclasses_for(ActionController::Base)
end
And when you reset it you would go:
ApplicationResetter.reset!

Thoughts?

I guess I could create a patch for this but as it's a pretty crucial
part of Rails it would require a lot of testing so there's use for me
spending time on it unless I get help testing. I also suspect there
might be some interesting issues, like for example why are controllers
cleared before dependencies are?

Cheers,
Jon
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to