Class: CampactUserService::Session
- Inherits:
-
Object
- Object
- CampactUserService::Session
- Defined in:
- lib/campact_user_service/session.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#session_cookie_name ⇒ Object
readonly
Returns the value of attribute session_cookie_name.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
Instance Method Summary collapse
- #destroy ⇒ Object
- #exists? ⇒ Boolean
- #has_hard_login_session? ⇒ Boolean
- #has_soft_login_session? ⇒ Boolean
-
#initialize(client, session_id, session_cookie_name) ⇒ Session
constructor
A new instance of Session.
- #user_id ⇒ Object
Constructor Details
#initialize(client, session_id, session_cookie_name) ⇒ Session
Returns a new instance of Session.
5 6 7 8 9 |
# File 'lib/campact_user_service/session.rb', line 5 def initialize(client, session_id, ) @client = client @session_id = session_id @session_cookie_name = end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/campact_user_service/session.rb', line 3 def client @client end |
#session_cookie_name ⇒ Object (readonly)
Returns the value of attribute session_cookie_name.
3 4 5 |
# File 'lib/campact_user_service/session.rb', line 3 def @session_cookie_name end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
3 4 5 |
# File 'lib/campact_user_service/session.rb', line 3 def session_id @session_id end |
Instance Method Details
#destroy ⇒ Object
27 28 29 |
# File 'lib/campact_user_service/session.rb', line 27 def destroy client.delete_request('/v1/sessions', cookies: { => session_id}) end |
#exists? ⇒ Boolean
11 12 13 |
# File 'lib/campact_user_service/session.rb', line 11 def exists? session && session['id'] end |
#has_hard_login_session? ⇒ Boolean
23 24 25 |
# File 'lib/campact_user_service/session.rb', line 23 def has_hard_login_session? session["permission_level"] == 'full' end |
#has_soft_login_session? ⇒ Boolean
19 20 21 |
# File 'lib/campact_user_service/session.rb', line 19 def has_soft_login_session? session["permission_level"] == 'limited' end |
#user_id ⇒ Object
15 16 17 |
# File 'lib/campact_user_service/session.rb', line 15 def user_id session["user_id"] end |