Chris Richards
2008-Feb-21 14:53 UTC
Reload classes if they are new/changed in Production Mode
Is there a way to check if there are any new classes or any existing
classes that have changed in the lib/ folder?, and if there are then to
reload them into Rails?
My application is a simply a parsing application that parses multiple
types of formatted documents. New parsers are added regularly and It
would be best for me if i could just drop another parser into the lib/
folder and have it included in the system, without having to restart the
rails application.
I already have a method that scans for Parsing classes to use:
parsers = []
ObjectSpace.each_object(Class) do |klass|
if klass.superclass==Parser &&
klass.methods.include?("is_compatible?") &&
klass.instance_methods.include?("parse")
parsers << klass
end
end
So basically, i need a scanner that will check every so often to see if
any new parsers have been added or any existing parsers changed, and if
so, then load them!!
Any help is appreciated,
Thanks
Chris
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I do not think this is possible as the app is loaded in memory in full when the (Mongrel) server starts. That is why having cron jobs is relatively expensive. Not much help, sorry. On Feb 21, 3:53 pm, Chris Richards <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Is there a way to check if there are any new classes or any existing > classes that have changed in the lib/ folder?, and if there are then to > reload them into Rails? > > My application is a simply a parsing application that parses multiple > types of formatted documents. New parsers are added regularly and It > would be best for me if i could just drop another parser into the lib/ > folder and have it included in the system, without having to restart the > rails application. > > I already have a method that scans for Parsing classes to use: > > parsers = [] > ObjectSpace.each_object(Class) do |klass| > if klass.superclass==Parser && > klass.methods.include?("is_compatible?") && > klass.instance_methods.include?("parse") > parsers << klass > end > end > > So basically, i need a scanner that will check every so often to see if > any new parsers have been added or any existing parsers changed, and if > so, then load them!! > > Any help is appreciated, > > Thanks > Chris > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---