Sha256: 14374d9fcc247394c10dd1294ada8c331ec921e085707662c662ceaf8ad4115e
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require File.join(File.dirname(__FILE__), "base") module Mack module RunnerHelpers # :nodoc: class Session < Mack::RunnerHelpers::Base attr_accessor :sess_id def start(request, response, cookies) if app_config.mack.use_sessions self.sess_id = retrieve_session_id(request, response, cookies) unless self.sess_id self.sess_id = create_new_session(request, response, cookies) else sess = Cachetastic::Caches::MackSessionCache.get(self.sess_id) if sess request.session = sess else # we couldn't find it in the store, so we need to create it: self.sess_id = create_new_session(request, response, cookies) end end end end def complete(request, response, cookies) unless response.redirection? request.session.delete(:tell) end Cachetastic::Caches::MackSessionCache.set(request.session.id, request.session) if app_config.mack.use_sessions end private def retrieve_session_id(request, response, cookies) cookies[app_config.mack.session_id] end def create_new_session(request, response, cookies) id = String.randomize(40).downcase cookies[app_config.mack.session_id] = {:value => id, :expires => nil} sess = Mack::Session.new(id) request.session = sess Cachetastic::Caches::MackSessionCache.set(id, sess) id end end # Session end # RunnerHelpers end # Mack
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mack-0.7.0.1 | lib/mack/runner_helpers/session.rb |
mack-0.7.0 | lib/mack/runner_helpers/session.rb |