Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Constant Reloading

#186

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)

Reported by bahuvrihi · March 11th, 2009 @ 02:20 PM

State: resolved
Milestone: none
Assigned to: bahuvrihi bahuvrihi

Activity

  1. bahuvrihi
    bahuvrihi

    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.

    March 11th, 2009 @ 02:44 PM

  2. bahuvrihi
    bahuvrihi
    • Assigned user set to bahuvrihi
    • State changed from new to resolved

    May 3rd, 2009 @ 08:51 AM

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.