From 202e4208c4d26f05ea856dbd57f4843ee3a7db29 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 23 Nov 2005 00:35:37 +0000 Subject: Correct spelling of persistent [Stefan Kaes]. Document and eliminate warnings in clear_persistent_model_associations. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3166 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_controller/session_management.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb index 0da594d638..827f8ebe46 100644 --- a/actionpack/lib/action_controller/session_management.rb +++ b/actionpack/lib/action_controller/session_management.rb @@ -11,7 +11,7 @@ module ActionController #:nodoc: base.extend(ClassMethods) base.send(:alias_method, :process_without_session_management_support, :process) base.send(:alias_method, :process, :process_with_session_management_support) - base.after_filter(:clear_persistant_model_associations) + base.after_filter(:clear_persistent_model_associations) end module ClassMethods @@ -115,11 +115,21 @@ module ActionController #:nodoc: request.session_options = self.class.session_options_for(request, action) process_without_session_management_support(request, response, method, *arguments) end - + private - def clear_persistant_model_associations #:doc: - if session = @session.instance_variable_get("@data") - session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) } + # Clear cached associations in session data so they don't overflow + # the database field. Only applies to ActiveRecordStore since there + # is not a standard way to iterate over session data. + def clear_persistent_model_associations #:doc: + if defined?(@session) and @session.instance_variables.include?('@data') + session_data = @session.instance_variable_get('@data') + if session_data and session_data.respond_to?(:each_value) + session_data.each_value do |obj| + if obj.respond_to?(:clear_association_cache) + obj.clear_association_cache + end + end + end end end end -- cgit v1.2.3