Rails 3 engine and code reloading in development mode

I have a rails 3 engine. In initializer it requires a bunch of files from some folder. In this file user of my engine defines code, business logic, configures engine, etc.. All this data is stored statically in my engine main module (in application attribute)

module MyEngine
  class << self
    def application
      @application ||= MyEngine::Application.new 
    end
  end
end

I want this files to be reloaded on each request in development mode. (So that the user don't have to reload server to see changes he just made) Of course I can do something like this instead of initializer

config.to_prepare do
  MyEngine.application.clear!
  load('some/file')  
end

But this way i will have issues (because constants defined in this file won't really be reloaded).

The ideal solution would be to make my whole engine reloadable on each request, but a have not found the way to do it.

6
задан tshepang 18 October 2013 в 14:18
поделиться