Class: HonestRenter::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tokenObject (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_sessionObject (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

Returns:

  • (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_atObject



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