Class: HonestRenter::Session
- Inherits:
-
Object
- Object
- HonestRenter::Session
- Defined in:
- lib/session.rb
Instance Attribute Summary collapse
-
#honr_authentication_token ⇒ Object
readonly
Returns the value of attribute honr_authentication_token.
-
#honr_session ⇒ Object
readonly
Returns the value of attribute honr_session.
Instance Method Summary collapse
- #expired? ⇒ Boolean
- #expires_at ⇒ Object
-
#initialize(honr_authentication_token, honr_session) ⇒ Session
constructor
A new instance of Session.
Constructor Details
#initialize(honr_authentication_token, honr_session) ⇒ Session
Returns a new instance of Session.
5 6 7 8 |
# File 'lib/session.rb', line 5 def initialize(honr_authentication_token, honr_session) @honr_authentication_token = honr_authentication_token.to_s @honr_session = JSON.parse(honr_session) rescue nil end |
Instance Attribute Details
#honr_authentication_token ⇒ Object (readonly)
Returns the value of attribute honr_authentication_token.
3 4 5 |
# File 'lib/session.rb', line 3 def honr_authentication_token @honr_authentication_token end |
#honr_session ⇒ Object (readonly)
Returns the value of attribute honr_session.
3 4 5 |
# File 'lib/session.rb', line 3 def honr_session @honr_session end |
Instance Method Details
#expired? ⇒ Boolean
15 16 17 18 |
# File 'lib/session.rb', line 15 def expired? return true if @honr_session.nil? || !@honr_session.is_a?(Hash) expires_at < Time.now end |
#expires_at ⇒ Object
10 11 12 13 |
# File 'lib/session.rb', line 10 def expires_at return Time.now if @honr_session.nil? Time.at(@honr_session['expires']) end |