lib/vkontakte_api/client.rb in vkontakte_api-0.2.1 vs lib/vkontakte_api/client.rb in vkontakte_api-1.0.rc
- old
+ new
@@ -1,24 +1,26 @@
module VkontakteApi
- # A class representing a connection to VK. It holds an access token.
+ # A class representing a connection to VK. It holds the access token.
class Client
+ include Resolver
+
# An access token needed by authorized requests.
- attr_reader :access_token
+ attr_reader :token
# A new API client.
- # @param [String] access_token An access token.
- def initialize(access_token = nil)
- @access_token = access_token
+ # @param [String, OAuth2::AccessToken] token An access token.
+ def initialize(token = nil)
+ if token.respond_to?(:token)
+ # token is an OAuth2::AccessToken
+ @token = token.token
+ else
+ # token is a String or nil
+ @token = token
+ end
end
# Is a `VkontakteApi::Client` instance authorized.
def authorized?
- !@access_token.nil?
- end
-
- # All unknown methods are delegated to a `VkontakteApi::Resolver` instance.
- def method_missing(method_name, *args, &block)
- args = args.first || {}
- VkontakteApi::Resolver.new(:access_token => @access_token).send(method_name, args, &block)
+ !@token.nil?
end
end
end