public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/ddollar/rails.git
New adventures in dependency reloading

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@429 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Sun Jan 16 09:50:36 -0800 2005
commit  ee014ef95ae9746b4228f3bc7c85ac0df28ba1df
tree    d60860f75c1dbeda5090b82259fcc45aa85e50c1
parent  394cf21ce73cae503f4c5272ef2a417df6fd21a5
...
158
159
160
161
 
162
163
164
...
158
159
160
 
161
162
163
164
0
@@ -158,7 +158,7 @@ class Fixtures < Hash
0
       ActiveRecord::Base.logger.level = Logger::ERROR
0
 
0
       fixtures = table_names.flatten.map do |table_name|
0
- Fixtures.new(connection, table_name.to_s, File.join(fixtures_directory, table_name.to_s))
0
+ Fixtures.new(connection, File.split(table_name.to_s).last, File.join(fixtures_directory, table_name.to_s))
0
       end
0
 
0
       connection.transaction do
...
13
14
15
 
 
16
17
18
...
26
27
28
29
 
30
31
32
33
34
35
36
37
38
39
40
41
 
42
43
44
...
13
14
15
16
17
18
19
20
...
28
29
30
 
31
32
 
 
 
 
 
 
 
 
 
 
 
33
34
35
36
0
@@ -13,6 +13,8 @@ module Dependencies
0
     if !loaded.include?(file_name)
0
       loaded << file_name
0
 
0
+ STDERR << "Loaded: #{file_name}\n"
0
+
0
       begin
0
         require_or_load(file_name)
0
       rescue LoadError
0
@@ -26,19 +28,9 @@ module Dependencies
0
   end
0
 
0
   def reload
0
- old_loaded = loaded
0
+ reloading = loaded.dup
0
     clear
0
-
0
- old_loaded.each do |file_name|
0
- next if loaded.include?(file_name)
0
-
0
- begin
0
- silence_warnings { load("#{file_name}.rb") }
0
- loaded << file_name
0
- rescue LoadError
0
- # The association didn't reside in its own file, so we assume it was required by other means
0
- end
0
- end
0
+ reloading.each { |file_name| depend_on(file_name, true) }
0
   end
0
   
0
   def clear
...
24
25
26
27
28
29
30
31
32
33
 
 
34
35
36
...
38
39
40
41
42
43
 
44
45
46
47
48
 
 
49
50
51
52
53
54
55
56
57
58
59
 
 
 
 
60
61
62
...
24
25
26
 
27
 
28
 
 
29
30
31
32
33
34
...
36
37
38
 
 
 
39
40
41
42
 
 
43
44
45
46
47
48
49
 
 
 
 
 
 
50
51
52
53
54
55
56
0
@@ -24,13 +24,11 @@
0
 require 'breakpoint'
0
 
0
 class Dispatcher
0
-
0
   class <<self
0
-
0
     def dispatch(cgi = CGI.new, session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS)
0
- Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI)) if defined?(BREAKPOINT_SERVER_PORT)
0
-
0
       begin
0
+ Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI)) if defined?(BREAKPOINT_SERVER_PORT)
0
+
0
         request = ActionController::CgiRequest.new(cgi, session_options)
0
         response = ActionController::CgiResponse.new(cgi)
0
     
0
@@ -38,25 +36,21 @@ class Dispatcher
0
 
0
         require_dependency("application")
0
         require_dependency(controller_path(controller_name, module_name))
0
-
0
- reload_application rescue nil # Ignore out of order reloading errors for Controllers
0
-
0
+
0
         controller_class(controller_name).process(request, response).out
0
       rescue Object => exception
0
         ActionController::Base.process_with_exception(request, response, exception).out
0
- ensure
0
- remove_class_hierarchy(controller_class(controller_name), ActionController::Base) if Dependencies.mechanism == :load
0
+ ensure
0
+ reset_application(controller_name) if Dependencies.mechanism == :load
0
         Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
0
       end
0
     end
0
     
0
     private
0
-
0
- def reload_application
0
- if Dependencies.mechanism == :load
0
- ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
0
- Dependencies.reload
0
- end
0
+ def reset_application(controller_name)
0
+ ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
0
+ Dependencies.clear
0
+ remove_class_hierarchy(controller_class(controller_name), ApplicationController)
0
       end
0
 
0
       def controller_path(controller_name, module_name = nil)

Comments

    No one has commented yet.