class Tinypass::AccessTokenList

Constants

MAX

Public Class Methods

new(input_tokens = nil) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 7
def initialize(input_tokens = nil)
  @tokens_hash = {}
  input_tokens = Array(input_tokens)

  input_tokens.each { |token| self << token }
end

Public Instance Methods

<<(token) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 23
def <<(token)
  key = token.token_data.rid

  @tokens_hash[key] = token
  shift until size <= MAX

  self[key]
end
Also aliased as: add
[](rid) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 19
def [](rid)
  @tokens_hash[rid.to_s]
end
access_tokens()
Alias for: tokens
add(token)
Alias for: <<
add_all(tokens) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 39
def add_all(tokens)
  self.push(*tokens)
end
contains?(rid)
Alias for: include?
delete(rid) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 62
def delete(rid)
  @tokens_hash.delete(rid)
end
Also aliased as: remove
each(*args, &block) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 49
def each(*args, &block)
  tokens.each(*args, &block)
end
empty?() click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 58
def empty?
  @tokens_hash.empty?
end
include?(rid) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 43
def include?(rid)
  rid = rid.to_s
  @tokens_hash.has_key?(rid)
end
Also aliased as: contains?
length() click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 53
def length
  tokens.size
end
Also aliased as: size
push(*args) click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 33
def push(*args)
  args.each do |token|
    self << token
  end
end
remove(rid)
Alias for: delete
shift() click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 67
def shift
  delete(@tokens_hash.keys.first)
end
size()
Alias for: length
tokens() click to toggle source
# File lib/tinypass/token/access_token_list.rb, line 14
def tokens
  @tokens_hash.values
end
Also aliased as: access_tokens