class ActionDispatch::Session::MongoidSessionStore
Constants
- ENV_SESSION_OPTIONS_KEY
- SESSION_RECORD_KEY
Private Instance Methods
destroy_session(env, session_id, options)
click to toggle source
# File lib/action_dispatch/session/mongoid_session_store.rb, line 41 def destroy_session(env, session_id, options) if sid = current_session_id(env) get_session_model(env, sid).destroy env[SESSION_RECORD_KEY] = nil end generate_sid unless options[:drop] end
find_session(id)
click to toggle source
# File lib/action_dispatch/session/mongoid_session_store.rb, line 58 def find_session(id) session_class.find_by_session_id(id) || session_class.new(:session_id => id, :data => {}) end
get_session(env, sid)
click to toggle source
# File lib/action_dispatch/session/mongoid_session_store.rb, line 20 def get_session(env, sid) return nil unless sid and session = session_class.find_by_session_id(sid) env[SESSION_RECORD_KEY] = session [sid, session.data] end
get_session_model(env, sid)
click to toggle source
# File lib/action_dispatch/session/mongoid_session_store.rb, line 50 def get_session_model(env, sid) if env[ENV_SESSION_OPTIONS_KEY][:id].nil? env[SESSION_RECORD_KEY] = find_session(sid) else env[SESSION_RECORD_KEY] ||= find_session(sid) end end
session_class()
click to toggle source
# File lib/action_dispatch/session/mongoid_session_store.rb, line 16 def session_class Mongoid::SessionStore::Session end
set_session(env, sid, session_data, options)
click to toggle source
# File lib/action_dispatch/session/mongoid_session_store.rb, line 26 def set_session(env, sid, session_data, options) record = get_session_model(env, sid) record.data = session_data return false unless record.save session_data = record.data if session_data && session_data.respond_to?(:each_value) session_data.each_value do |obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) end end sid end