aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/session_management.rb
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-02 16:22:53 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-03-03 15:49:52 -0800
commitbf9913f8f43a2436c644ad893d3d7034f7d7e256 (patch)
tree7303219f42781fe8d70d5c9b80ba54107986a604 /actionpack/lib/action_controller/metal/session_management.rb
parent9731c5213b9f1a46c478da862b43cbf708da40da (diff)
downloadrails-bf9913f8f43a2436c644ad893d3d7034f7d7e256.tar.gz
rails-bf9913f8f43a2436c644ad893d3d7034f7d7e256.tar.bz2
rails-bf9913f8f43a2436c644ad893d3d7034f7d7e256.zip
Move session_store and session_options to the AC configuration object
Diffstat (limited to 'actionpack/lib/action_controller/metal/session_management.rb')
-rw-r--r--actionpack/lib/action_controller/metal/session_management.rb35
1 files changed, 24 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/metal/session_management.rb b/actionpack/lib/action_controller/metal/session_management.rb
index 6997257844..264250db1a 100644
--- a/actionpack/lib/action_controller/metal/session_management.rb
+++ b/actionpack/lib/action_controller/metal/session_management.rb
@@ -2,27 +2,40 @@ module ActionController #:nodoc:
module SessionManagement #:nodoc:
extend ActiveSupport::Concern
+ included do
+ self.config.session_store ||= :cookie_store
+ self.config.session_options ||= {}
+ end
+
module ClassMethods
# Set the session store to be used for keeping the session data between requests.
# By default, sessions are stored in browser cookies (<tt>:cookie_store</tt>),
# but you can also specify one of the other included stores (<tt>:active_record_store</tt>,
# <tt>:mem_cache_store</tt>, or your own custom class.
def session_store=(store)
- if store == :active_record_store
- self.session_store = ActiveRecord::SessionStore
- else
- @@session_store = store.is_a?(Symbol) ?
- ActionDispatch::Session.const_get(store.to_s.camelize) :
- store
- end
+ ActiveSupport::Deprecation.warn "Setting session_store directly on ActionController::Base is deprecated. " \
+ "Please set it on config.action_controller.session_store"
+ config.session_store = store
+ end
+
+ def session_options=(opts)
+ ActiveSupport::Deprecation.warn "Setting seession_options directly on ActionController::Base is deprecated. " \
+ "Please set it on config.action_controller.session_options"
+ config.session_store = opts
+ end
+
+ def session_options
+ config.session_options
end
- # Returns the session store class currently used.
def session_store
- if defined? @@session_store
- @@session_store
+ case store = config.session_store
+ when :active_record_store
+ ActiveRecord::SessionStore
+ when Symbol
+ ActionDispatch::Session.const_get(store.to_s.camelize)
else
- ActionDispatch::Session::CookieStore
+ store
end
end