class ActionDispatch::Session::MongoStoreBase
Constants
- ENV_SESSION_OPTIONS_KEY
- SESSION_RECORD_KEY
Public Class Methods
session_class()
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 9 def self.session_class self::Session end
Private Instance Methods
destroy(env)
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 55 def destroy(env) sid = current_session_id(env) return unless sid _, record = get_session_record(env, sid) record.destroy env[SESSION_RECORD_KEY] = nil end
destroy_session(env, _session_id, options)
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 50 def destroy_session(env, _session_id, options) destroy(env) generate_sid unless options[:drop] end
find_or_initialize_session(id)
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 35 def find_or_initialize_session(id) existing_session = (id && session_class.where(:_id => id).first) session = existing_session if existing_session session ||= session_class.new(:_id => generate_sid) [session._id, session] end
get_session(env, sid)
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 19 def get_session(env, sid) id, record = find_or_initialize_session(sid) env[SESSION_RECORD_KEY] = record [id, record.data] end
get_session_record(env, sid)
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 42 def get_session_record(env, sid) if env[ENV_SESSION_OPTIONS_KEY][:id].nil? || !env[SESSION_RECORD_KEY] sid, env[SESSION_RECORD_KEY] = find_or_initialize_session(sid) end [sid, env[SESSION_RECORD_KEY]] end
session_class()
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 15 def session_class self.class.session_class end
set_session(env, sid, session_data, _options = {}) { || ... }
click to toggle source
# File lib/mongo_session_store/mongo_store_base.rb, line 25 def set_session(env, sid, session_data, _options = {}) id, record = get_session_record(env, sid) record.data = session_data yield if block_given? # Rack spec dictates that set_session should return true or false # depending on whether or not the session was saved or not. # However, ActionPack seems to want a session id instead. record.save ? id : false end