lib/merb/merb_dispatcher.rb in merb-0.2.0 vs lib/merb/merb_dispatcher.rb in merb-0.3.0
- old
+ new
@@ -3,10 +3,14 @@
class Dispatcher
class << self
attr_accessor :path_prefix
+ def use_mutex=(val)
+ @@use_mutex = val
+ end
+
@@mutex = Mutex.new
@@use_mutex = ::Merb::Server.use_mutex
# This is where we grab the incoming request PATH_INFO
# and use that in the merb routematcher to determine
# which controller and method to run.
@@ -43,11 +47,11 @@
end
def route_path(path)
path = path.sub(/\/+/, '/').sub(/\?.*$/, '')
path = path[0..-2] if (path[-1] == ?/) && path.size > 1
- Merb::RouteMatcher.new.route_request(path)
+ Merb::RouteMatcher.route_request(path)
end
# take a controller class name string and reload or require
# the right controller file then CamelCase it and turn it
# into a new object passing in the request and response.
@@ -55,17 +59,20 @@
def instantiate_controller(controller_name, req, env, params, res)
if !File.exist?(DIST_ROOT+"/app/controllers/#{controller_name.snake_case}.rb")
raise "Bad controller! #{controller_name.snake_case}"
end unless $TESTING
begin
- controller_name.import
+ unless MERB_ENV == 'production'
+ Object.send(:remove_const, controller_name.camel_case.intern) rescue nil
+ load(controller_name.snake_case + '.rb')
+ end
return Object.const_get( controller_name.camel_case ).new(req, env, params, res)
rescue RuntimeError
warn "Error getting instance of '#{controller_name.camel_case}': #{$!}"
raise $!
end
end
-
+
end # end class << self
end
end
\ No newline at end of file