ActionController::Dispatcher#cleanup_application does this:
def cleanup_application(force = false)
if Dependencies.load? || force
ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
Dependencies.clear
ActiveRecord::Base.clear_reloadable_connections! if
defined?(ActiveRecord)
end
end
where
def self.reset_subclasses #:nodoc:
nonreloadables = []
subclasses.each do |klass|
unless Dependencies.autoloaded? klass
nonreloadables << klass
next
end
klass.instance_variables.each { |var|
klass.send(:remove_instance_variable, var) }
klass.instance_methods(false).each { |m| klass.send :undef_method, m }
end
@@subclasses = {}
nonreloadables.each { |klass| (@@subclasses[klass.superclass]
||= []) << klass }
end
Why do ARs need that cleanup?
-- fxn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---
On E, 2007-11-19 at 11:26 +0100, Xavier Noria wrote:> Why do ARs need that cleanup?Probably because they have to reload the database schema which is partly described in their class instance variables on every request. For example, columns: # Returns an array of column objects for the table associated with this class. def columns unless @columns @columns = connection.columns(table_name, "#{name} Columns") @columns.each {|column| column.primary = column.name =primary_key} end @columns end -- Tarmo Tänav <tarmo@itech.ee> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 19, 12:16 pm, Tarmo Tänav <ta...@itech.ee> wrote:> On E, 2007-11-19 at 11:26 +0100, Xavier Noria wrote: > > > Why do ARs need that cleanup? > > Probably because they have to reload the database schema > which is partly described in their class instance variables > on every request.But if the class was autoloaded wouldn''t that be a side-effect of remove_const Model + const_missing Model as with the rest of autoloaded classes? Why are those special removals needed? -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2007-Nov-20 06:20 UTC
Re: purpose of ActiveRecord::Base.reset_subclasses?
> But if the class was autoloaded wouldn''t that be a side-effect of > remove_const Model + const_missing Model as with the rest of > autoloaded classes? Why are those special removals needed?Indeed that does seem unneeded at first glance. Another thing to test out once 2.0 is out the door I guess ;) -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---