Sha256: 9143f21562ed58074abe8c7c751cf7b4c88bb9f4d0629b4acd5109fe3434ae92
Contents?: true
Size: 970 Bytes
Versions: 7
Compression:
Stored size: 970 Bytes
Contents
module VkontakteApi # A class representing a connection to VK. It holds the access token. class Client include Resolver # An access token needed by authorized requests. # @return [String] attr_reader :token # Current user id. # @return [Integer] attr_reader :user_id # A new API client. # If given an `OAuth2::AccessToken` instance, it extracts and keeps # the token string and the user id; otherwise it just stores the given token. # @param [String, OAuth2::AccessToken] token An access token. def initialize(token = nil) if token.respond_to?(:token) && token.respond_to?(:params) # token is an OAuth2::AccessToken @token = token.token @user_id = token.params['user_id'] else # token is a String or nil @token = token end end # Is a `VkontakteApi::Client` instance authorized. def authorized? !@token.nil? end end end
Version data entries
7 entries across 7 versions & 1 rubygems