diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-13 08:31:32 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-13 08:31:32 +0000 |
commit | ebb7bd78351b7975f28fdcbadbbf0fe4804be2f2 (patch) | |
tree | 7be64a13212fce30d2ed351ed25d6ef3aeae9e59 /actionpack/lib/action_controller/session_management.rb | |
parent | 48018bf4b5e5a2e173b4744abddc3e8cb590b4df (diff) | |
download | rails-ebb7bd78351b7975f28fdcbadbbf0fe4804be2f2.tar.gz rails-ebb7bd78351b7975f28fdcbadbbf0fe4804be2f2.tar.bz2 rails-ebb7bd78351b7975f28fdcbadbbf0fe4804be2f2.zip |
Added easy assignment of fragment cache store through use of symbols for included stores (old way still works too)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2230 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 | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb index 193910d470..b0a457932d 100644 --- a/actionpack/lib/action_controller/session_management.rb +++ b/actionpack/lib/action_controller/session_management.rb @@ -1,12 +1,17 @@ +require 'action_controller/session/drb_store' +require 'action_controller/session/mem_cache_store' +if Object.const_defined?(:ActiveRecord) + require 'action_controller/session/active_record_store' +end + module ActionController #:nodoc: module SessionManagement #:nodoc: def self.append_features(base) super base.extend(ClassMethods) - base.class_eval do - alias_method :process_without_session_management_support, :process - alias_method :process, :process_with_session_management_support - end + 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) end module ClassMethods @@ -15,7 +20,7 @@ module ActionController #:nodoc: # :mem_cache_store, or :memory_store) or use your own class. def session_store=(store) ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager] = - store.is_a?(Symbol) ? CGI::Session.const_get(store.to_s.camelize) : store + store.is_a?(Symbol) ? CGI::Session.const_get(store == :drb_store ? "DRbStore" : store.to_s.camelize) : store end # Returns the session store class currently used. @@ -100,5 +105,11 @@ 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: + session = @session.instance_variable_get("@data") + session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) } if session + end end end |