diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-12 05:51:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-12 05:51:02 +0000 |
commit | 050c3964d8fe8d68c03fff593e3c09b5eae77a46 (patch) | |
tree | 9331224443d2415be34543af3a94d415c7020d31 /actionpack/lib/action_controller/session_management.rb | |
parent | 838ec413ebe08be71eea3dec0b061c6f609c839f (diff) | |
download | rails-050c3964d8fe8d68c03fff593e3c09b5eae77a46.tar.gz rails-050c3964d8fe8d68c03fff593e3c09b5eae77a46.tar.bz2 rails-050c3964d8fe8d68c03fff593e3c09b5eae77a46.zip |
Stopped the massive bleeding of concerns into ActionController::Base. Base no longer knows about flash, filters, or components. This may well have introduced some instability, please do test with apps, especially the ones using components. [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3580 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/session_management.rb')
-rw-r--r-- | actionpack/lib/action_controller/session_management.rb | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb index 950f48abf4..408ef2790e 100644 --- a/actionpack/lib/action_controller/session_management.rb +++ b/actionpack/lib/action_controller/session_management.rb @@ -6,11 +6,14 @@ end module ActionController #:nodoc: module SessionManagement #:nodoc: - def self.append_features(base) - super + def self.included(base) base.extend(ClassMethods) - base.send(:alias_method, :process_without_session_management_support, :process) - base.send(:alias_method, :process, :process_with_session_management_support) + + base.send :alias_method, :process_without_session_management_support, :process + base.send :alias_method, :process, :process_with_session_management_support + + base.send :alias_method, :process_cleanup_without_session_management_support, :process_cleanup + base.send :alias_method, :process_cleanup, :process_cleanup_with_session_management_support end module ClassMethods @@ -110,26 +113,30 @@ module ActionController #:nodoc: end def process_with_session_management_support(request, response, method = :perform_action, *arguments) #:nodoc: - unless @parent_controller - # only determine session options if this isn't a controller created for component request processing - action = request.parameters["action"] || "index" - request.session_options = self.class.session_options_for(request, action) - end + set_session_options(request) process_without_session_management_support(request, response, method, *arguments) end private + def set_session_options(request) + request.session_options = self.class.session_options_for(request, request.parameters["action"] || "index") + end + + def process_cleanup_with_session_management_support + process_cleanup_without_session_management_support + clear_persistent_model_associations + end + # 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') + if defined?(@session) && @session.instance_variables.include?('@data') session_data = @session.instance_variable_get('@data') - if session_data and session_data.respond_to?(:each_value) + + if session_data && session_data.respond_to?(:each_value) session_data.each_value do |obj| - if obj.respond_to?(:clear_association_cache) - obj.clear_association_cache - end + obj.clear_association_cache if obj.respond_to?(:clear_association_cache) end end end |