Class: AngelList::Auth
- Inherits:
-
Object
- Object
- AngelList::Auth
- Defined in:
- lib/angel_list/auth.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#options ⇒ Object
Returns the value of attribute options.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #code(c) ⇒ Object
- #from_hash(token) ⇒ Object
- #get_client ⇒ Object
-
#initialize(opts) ⇒ Auth
constructor
A new instance of Auth.
- #redirect_url ⇒ Object
Constructor Details
#initialize(opts) ⇒ Auth
Returns a new instance of Auth.
7 8 9 10 11 12 13 14 |
# File 'lib/angel_list/auth.rb', line 7 def initialize(opts) self. = Hashie::Mash.new self. = self..merge(AngelList::Config.) if AngelList::Config.methods.include? :options self. = self..merge(opts) self. = self..merge(:site => 'https://angel.co/') if self.[:site] == nil self.client = get_client self end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/angel_list/auth.rb', line 5 def client @client end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/angel_list/auth.rb', line 5 def @options end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/angel_list/auth.rb', line 5 def token @token end |
Instance Method Details
#code(c) ⇒ Object
27 28 29 30 |
# File 'lib/angel_list/auth.rb', line 27 def code(c) self.token = self.client.auth_code.get_token(c, :redirect_uri => self.[:redirect_uri]) self end |
#from_hash(token) ⇒ Object
32 33 34 35 |
# File 'lib/angel_list/auth.rb', line 32 def from_hash(token) self.token = OAuth2::AccessToken.new(self.client, token) self end |
#get_client ⇒ Object
20 21 22 23 24 25 |
# File 'lib/angel_list/auth.rb', line 20 def get_client OAuth2::Client.new(self.[:client_id], self.[:client_secret], :site => self.[:site], :authorize_url => '/api/oauth/authorize', :token_url => '/api/oauth/token') end |
#redirect_url ⇒ Object
16 17 18 |
# File 'lib/angel_list/auth.rb', line 16 def redirect_url self.client.auth_code.(:redirect_uri => self.[:redirect_uri]) end |