Class: ActionDispatch::Session::AbstractStore
- Inherits:
-
Object
- Object
- ActionDispatch::Session::AbstractStore
- Defined in:
- lib/action_dispatch/middleware/session/abstract_store.rb
Direct Known Subclasses
Defined Under Namespace
Classes: OptionsHash, SessionHash
Constant Summary collapse
- ENV_SESSION_KEY =
'rack.session'.freeze
- ENV_SESSION_OPTIONS_KEY =
'rack.session.options'.freeze
- DEFAULT_OPTIONS =
{ :key => '_session_id', :path => '/', :domain => nil, :expire_after => nil, :secure => false, :httponly => true, :cookie_only => true }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ AbstractStore
constructor
A new instance of AbstractStore.
Constructor Details
#initialize(app, options = {}) ⇒ AbstractStore
Returns a new instance of AbstractStore.
139 140 141 142 143 144 145 |
# File 'lib/action_dispatch/middleware/session/abstract_store.rb', line 139 def initialize(app, = {}) @app = app @default_options = DEFAULT_OPTIONS.merge() @key = @default_options.delete(:key).freeze @cookie_only = @default_options.delete(:cookie_only) ensure_session_key! end |
Instance Method Details
#call(env) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/action_dispatch/middleware/session/abstract_store.rb', line 147 def call(env) prepare!(env) response = @app.call(env) session_data = env[ENV_SESSION_KEY] = env[ENV_SESSION_OPTIONS_KEY] if !session_data.is_a?(AbstractStore::SessionHash) || session_data.loaded? || [:expire_after] session_data.send(:load!) if session_data.is_a?(AbstractStore::SessionHash) && !session_data.loaded? sid = [:id] || generate_sid session_data = session_data.to_hash value = set_session(env, sid, session_data) return response unless value = { :value => value } unless [:expire_after].nil? [:expires] = Time.now + .delete(:expire_after) end request = ActionDispatch::Request.new(env) (request, .merge!()) end response end |