Class: Tinypass::AccessTokenStore
- Inherits:
-
Object
- Object
- Tinypass::AccessTokenStore
- Defined in:
- lib/tinypass/token/access_token_store.rb
Instance Attribute Summary collapse
-
#raw_cookie ⇒ Object
readonly
Returns the value of attribute raw_cookie.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #find_active_token(regexp) ⇒ Object
- #get_access_token(rid) ⇒ Object
- #has_token?(rid) ⇒ Boolean
-
#initialize(config = nil) ⇒ AccessTokenStore
constructor
A new instance of AccessTokenStore.
- #load_tokens_from_cookie(cookies, name = nil) ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ AccessTokenStore
Returns a new instance of AccessTokenStore.
10 11 12 13 |
# File 'lib/tinypass/token/access_token_store.rb', line 10 def initialize(config = nil) @config = config @tokens = AccessTokenList.new end |
Instance Attribute Details
#raw_cookie ⇒ Object (readonly)
Returns the value of attribute raw_cookie.
8 9 10 |
# File 'lib/tinypass/token/access_token_store.rb', line 8 def end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
8 9 10 |
# File 'lib/tinypass/token/access_token_store.rb', line 8 def tokens @tokens end |
Instance Method Details
#find_active_token(regexp) ⇒ Object
43 44 45 46 47 48 49 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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) ⇒ Boolean
39 40 41 |
# File 'lib/tinypass/token/access_token_store.rb', line 39 def has_token?(rid) tokens.contains?(rid.to_s) end |
#load_tokens_from_cookie(cookies, name = nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/tinypass/token/access_token_store.rb', line 15 def (, name = nil) name ||= Config.(Tinypass.aid) = .respond_to?(:to_str) ? : [name] if @tokens = ClientParser.new.parse_access_tokens(URI.unescape()) end end |