Class: AlexaRuby::Session
- Inherits:
-
Object
- Object
- AlexaRuby::Session
- Defined in:
- lib/alexa_ruby/session.rb
Overview
Class handles the session object in request
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#new ⇒ Object
Returns the value of attribute new.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#access_token ⇒ String
Get user access token.
-
#attributes? ⇒ Boolean
Session attributes present?.
-
#initialize(session) ⇒ Session
constructor
Initialize new user session.
-
#new? ⇒ Boolean
Is it a new user session?.
-
#user_defined? ⇒ Boolean
Is user defined?.
-
#user_id ⇒ String
Get user ID.
Constructor Details
#initialize(session) ⇒ Session
Initialize new user session
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/alexa_ruby/session.rb', line 9 def initialize(session) if session.nil? || session[:new].nil? || session[:sessionId].nil? raise ArgumentError, 'Invalid Session' end @new = session[:new] @session_id = session[:sessionId] @attributes = session[:attributes].nil? ? {} : session[:attributes] @user = session[:user] end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/alexa_ruby/session.rb', line 4 def attributes @attributes end |
#new ⇒ Object
Returns the value of attribute new.
4 5 6 |
# File 'lib/alexa_ruby/session.rb', line 4 def new @new end |
#session_id ⇒ Object
Returns the value of attribute session_id.
4 5 6 |
# File 'lib/alexa_ruby/session.rb', line 4 def session_id @session_id end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'lib/alexa_ruby/session.rb', line 4 def user @user end |
Instance Method Details
#access_token ⇒ String
Get user access token
44 45 46 |
# File 'lib/alexa_ruby/session.rb', line 44 def access_token @user[:accessToken] if @user end |
#attributes? ⇒ Boolean
Session attributes present?
51 52 53 |
# File 'lib/alexa_ruby/session.rb', line 51 def attributes? !@attributes.empty? end |
#new? ⇒ Boolean
Is it a new user session?
23 24 25 |
# File 'lib/alexa_ruby/session.rb', line 23 def new? @new end |
#user_defined? ⇒ Boolean
Is user defined?
30 31 32 |
# File 'lib/alexa_ruby/session.rb', line 30 def user_defined? !@user.nil? || !@user[:userId].nil? end |
#user_id ⇒ String
Get user ID
37 38 39 |
# File 'lib/alexa_ruby/session.rb', line 37 def user_id @user[:userId] if @user end |