Class: ASeriesOfTubes::TubeState::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/a_series_of_tubes/tube_state/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Session

Returns a new instance of Session.



9
10
11
12
13
14
# File 'lib/a_series_of_tubes/tube_state/session.rb', line 9

def initialize request
  @request = request
  @name = "_#{APP_NAME}"
  @store = read_or_create_session_cookie
  @flash = TubeState::Flash.new (self.store['flash'] || {})
end

Instance Attribute Details

#flashObject (readonly)

Returns the value of attribute flash.



7
8
9
# File 'lib/a_series_of_tubes/tube_state/session.rb', line 7

def flash
  @flash
end

Instance Method Details

#[](key) ⇒ Object



16
17
18
# File 'lib/a_series_of_tubes/tube_state/session.rb', line 16

def [] key
  self.store[key]
end

#[]=(key, value) ⇒ Object



20
21
22
# File 'lib/a_series_of_tubes/tube_state/session.rb', line 20

def []= key, value
  self.store[key] = value
end

#store_session(response) ⇒ Object



24
25
26
27
# File 'lib/a_series_of_tubes/tube_state/session.rb', line 24

def store_session response
  self.store['flash'] = @flash.next
  response.set_cookie self.name, generate_cookie_hash
end