Class: GData4Ruby::OAuthService

Inherits:
Base
  • Object
show all
Defined in:
lib/gdata4ruby/oauth_service.rb

Overview

The service class is the main handler for all direct interactions with the Google Data API.

Constant Summary

Constants inherited from Base

Base::AUTH_URL

Instance Attribute Summary collapse

Attributes inherited from Base

#debug, #gdata_version, #proxy_info, #use_ssl

Instance Method Summary collapse

Methods inherited from Base

#create_url, #log, #send_request

Constructor Details

#initialize(attributes = {}) ⇒ OAuthService

Accepts an optional attributes hash for initialization values, most likely :gdata_version



29
30
31
32
33
34
35
36
# File 'lib/gdata4ruby/oauth_service.rb', line 29

def initialize(attributes = {})
  super(attributes)
  attributes.each do |key, value|
    if self.respond_to?("#{key}=")
      self.send("#{key}=", value)
    end
  end    
end

Instance Attribute Details

#access_tokenObject (readonly)

Convenience attribute contains the currently OAuth access token



26
27
28
# File 'lib/gdata4ruby/oauth_service.rb', line 26

def access_token
  @access_token
end

Instance Method Details

#authenticate(options = {}) ⇒ Object

The method is a generic hash to allow subclasses to easily receive args for their own type of authentication In this case, we’re using an OAuth AccessToken - oauth.rubyforge.org/rdoc/classes/OAuth/AccessToken.html



40
41
42
# File 'lib/gdata4ruby/oauth_service.rb', line 40

def authenticate(options = {})
  @access_token = options[:access_token]
end

#authenticated?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/gdata4ruby/oauth_service.rb', line 49

def authenticated?
  return (@access_token != nil)
end

#reauthenticate(options = {}) ⇒ Object



44
45
46
# File 'lib/gdata4ruby/oauth_service.rb', line 44

def reauthenticate(options = {})
  @access_token ||= options[:access_token]
end