class Tinypass::AccessTokenStore
Attributes
tokens[R]
Public Class Methods
new(config = nil)
click to toggle source
# File lib/tinypass/token/access_token_store.rb, line 10 def initialize(config = nil) @config = config @tokens = AccessTokenList.new end
Public Instance Methods
find_active_token(regexp)
click to toggle source
# File lib/tinypass/token/access_token_store.rb, line 43 def find_active_token(regexp) tokens.each do |token| return token if token.rid =~ regexp && !token.expired? end nil end
get_access_token(rid)
click to toggle source
# File lib/tinypass/token/access_token_store.rb, line 24 def get_access_token(rid) rid = rid.to_s return tokens[rid] if tokens[rid] token = AccessToken.new(rid, -1) if tokens.size == 0 token.access_state = AccessState::NO_TOKENS_FOUND else token.access_state = AccessState::RID_NOT_FOUND end return token end
has_token?(rid)
click to toggle source
# File lib/tinypass/token/access_token_store.rb, line 39 def has_token?(rid) tokens.contains?(rid.to_s) end
Protected Instance Methods
clean_expired_tokens()
click to toggle source
# File lib/tinypass/token/access_token_store.rb, line 53 def clean_expired_tokens @tokens.dup.each do |token| @tokens.delete(token.rid) if token.expired? || (token.metered? && token.trial_dead?) end end