# Reload classes if they are new/changed in Production Mode

**URL:** <https://www.ruby-forum.com/t/reload-classes-if-they-are-new-changed-in-production-mode/129784>\
**Category:** Rails\
**Created:** [February 21, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/reload-classes-if-they-are-new-changed-in-production-mode/129784 "2008-02-21T15:53:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [February 21, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/reload-classes-if-they-are-new-changed-in-production-mode/129784/1 "2008-02-21T15:53:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [February 21, 2008, 4:59pm UTC](https://www.ruby-forum.com/t/reload-classes-if-they-are-new-changed-in-production-mode/129784/2 "2008-02-21T16:59:43Z")

</div>

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 R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
