Class: Radio::HTTP::Session
- Inherits:
-
Object
- Object
- Radio::HTTP::Session
- Defined in:
- lib/radio/http/session.rb
Constant Summary collapse
- CODES =
('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
- COOKIE_KEY =
'ham21-radio-session'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Session
constructor
A new instance of Session.
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
38 39 |
# File 'lib/radio/http/session.rb', line 38 def initialize end |
Class Method Details
.prepare(request, response) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/radio/http/session.rb', line 26 def self.prepare request, response @sessions ||= {} session_id = request.[COOKIE_KEY] session = @sessions[session_id] unless session session_id = (0...24).collect{CODES.sample}.join session = @sessions[session_id] = new Rack::Utils.(response.headers, COOKIE_KEY, session_id) end session end |