Module: EuPago::Current

Defined in:
lib/ruby-eupago/current.rb

Class Method Summary collapse

Class Method Details

.access_tokenObject



11
12
13
# File 'lib/ruby-eupago/current.rb', line 11

def self.access_token
  @auth[:access_token] if @auth && !@auth.empty?
end

.auth=(value) ⇒ Object



6
7
8
9
# File 'lib/ruby-eupago/current.rb', line 6

def self.auth=(value)
  @auth = Hash[value.map { |(k, v)| [k.to_sym, v] }]
  @token_expires_at = Time.now + @auth[:expires_in].to_i if @auth[:expires_in]
end

.logged_in?Boolean



21
22
23
# File 'lib/ruby-eupago/current.rb', line 21

def self.logged_in?
  !access_token.nil? && !access_token.empty? && !token_expired?
end

.token_expired?Boolean



15
16
17
18
19
# File 'lib/ruby-eupago/current.rb', line 15

def self.token_expired?
  return true if @token_expires_at.nil?

  Time.now >= @token_expires_at
end