Constant Reloading
Reported by bahuvrihi | March 11th, 2009 @ 02:20 PM
Constant should have a way to specify constantize in a
development mode. In development mode the require_path is loaded
rather than required, and the constant is removed beforehand... the
same way controllers are reloaded.
# load the require_path in dev mode so that
# controllers will be reloaded each time
if development? && const.require_path
parent = Tap::Support::Constant.constantize(const.nesting) { nil }
if parent && parent.const_defined?(const.const_name)
parent.send(:remove_const, const.const_name)
end
load const.require_path
end
This is an entirely imperfect system however:
- if the file has any side effects, they may not be rolled back (ie anything other than defining the constant)
- if the file requires other files, they will not be reloaded (although they should remain active)
Comments and changes to this ticket
-
bahuvrihi March 11th, 2009 @ 02:44 PM
This immediately became an issue with this:
require 'tap/controller' require 'tap/http/utils' module Tap module Http # ::controller # ::ubiquity class Capture < Tap::Controller include Tap::Http::Utils class << self def cmd(what) %Q{ displayMessage("http://localhost:8080/capture/redirect"); displayMessage(jQuery('body').innerHTML); } end def preview(what) "#{what} is the what" end end
As a controller, the server tries to unload this. But as a ubiquity command, the file has already been required. As a result, when the controller unloads it cannot be reloaded and I get a dead connection.
Unloading needs to check if the file has already been required... if so, don't unload.
-
bahuvrihi May 3rd, 2009 @ 08:51 AM
- Assigned user set to bahuvrihi
- State changed from new to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A framework for making configurable, file-based tasks and workflows.