Class: SessionInstance
- Inherits:
-
Object
- Object
- SessionInstance
- Defined in:
- lib/primate/session.rb
Overview
Internal session instance class (used by framework)
Instance Method Summary collapse
-
#create(data) ⇒ void
Create a new session with data.
-
#destroy ⇒ void
Destroy the session.
-
#exists ⇒ Boolean
Check if session exists.
-
#get ⇒ Hash
Get session data (raises if no session).
-
#id ⇒ String
Get the session ID.
-
#initialize(session, helpers) ⇒ SessionInstance
constructor
Initialize session with JavaScript session object and helpers.
-
#set(data) ⇒ void
Set session data.
-
#try ⇒ Hash
Try to get session data (returns empty if no session).
Constructor Details
#initialize(session, helpers) ⇒ SessionInstance
Initialize session with JavaScript session object and helpers
75 76 77 78 |
# File 'lib/primate/session.rb', line 75 def initialize(session, helpers) @session = session @helpers = helpers end |
Instance Method Details
#create(data) ⇒ void
This method returns an undefined value.
Create a new session with data
98 99 100 |
# File 'lib/primate/session.rb', line 98 def create(data) @session.create(data) end |
#destroy ⇒ void
This method returns an undefined value.
Destroy the session
127 128 129 |
# File 'lib/primate/session.rb', line 127 def destroy @session.destroy end |
#exists ⇒ Boolean
Check if session exists
90 91 92 |
# File 'lib/primate/session.rb', line 90 def exists @session['exists'] end |
#get ⇒ Hash
Get session data (raises if no session)
105 106 107 |
# File 'lib/primate/session.rb', line 105 def get @session.get end |
#id ⇒ String
Get the session ID
83 84 85 |
# File 'lib/primate/session.rb', line 83 def id @session['id'] end |
#set(data) ⇒ void
This method returns an undefined value.
Set session data
120 121 122 |
# File 'lib/primate/session.rb', line 120 def set(data) @session.set(data) end |
#try ⇒ Hash
Try to get session data (returns empty if no session)
112 113 114 |
# File 'lib/primate/session.rb', line 112 def try @session.try end |