Class: BetterAlexaRubyKit::Session
- Inherits:
-
Object
- Object
- BetterAlexaRubyKit::Session
- Defined in:
- lib/better_alexa_rubykit/session.rb
Overview
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 ⇒ Object
-
#has_attributes? ⇒ Boolean
Check to see if attributes are present.
-
#initialize(session) ⇒ Session
constructor
A new instance of Session.
-
#new? ⇒ Boolean
Returns whether this is a new session or not.
-
#user_defined? ⇒ Boolean
Returns true if a user is defined.
-
#user_id ⇒ Object
Returns the user_id.
Constructor Details
#initialize(session) ⇒ Session
Returns a new instance of Session.
5 6 7 8 9 10 11 |
# File 'lib/better_alexa_rubykit/session.rb', line 5 def initialize (session) raise ArgumentError, 'Invalid Session' if session.nil? || session['new'].nil? || session['sessionId'].nil? @new = session['new'] @session_id = session['sessionId'] session['attributes'].nil? ? @attributes = Hash.new : @attributes = session['attributes'] @user = session['user'] end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/better_alexa_rubykit/session.rb', line 4 def attributes @attributes end |
#new ⇒ Object
Returns the value of attribute new.
4 5 6 |
# File 'lib/better_alexa_rubykit/session.rb', line 4 def new @new end |
#session_id ⇒ Object
Returns the value of attribute session_id.
4 5 6 |
# File 'lib/better_alexa_rubykit/session.rb', line 4 def session_id @session_id end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'lib/better_alexa_rubykit/session.rb', line 4 def user @user end |
Instance Method Details
#access_token ⇒ Object
28 29 30 |
# File 'lib/better_alexa_rubykit/session.rb', line 28 def access_token @user['accessToken'] if @user end |
#has_attributes? ⇒ Boolean
Check to see if attributes are present.
33 34 35 |
# File 'lib/better_alexa_rubykit/session.rb', line 33 def has_attributes? !@attributes.empty? end |
#new? ⇒ Boolean
Returns whether this is a new session or not.
14 15 16 |
# File 'lib/better_alexa_rubykit/session.rb', line 14 def new? !!@new end |
#user_defined? ⇒ Boolean
Returns true if a user is defined.
19 20 21 |
# File 'lib/better_alexa_rubykit/session.rb', line 19 def user_defined? !@user.nil? || !@user['userId'].nil? end |
#user_id ⇒ Object
Returns the user_id.
24 25 26 |
# File 'lib/better_alexa_rubykit/session.rb', line 24 def user_id @user['userId'] if @user end |