Class: Oauth::Provider
- Inherits:
-
Object
- Object
- Oauth::Provider
- Includes:
- Mongoid::Document
- Defined in:
- lib/oauth/provider.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.request(url, request_params, method = 'get', format = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/oauth/provider.rb', line 36 def request(url, request_params, method = 'get', format = nil) uri = URI(url) begin if method == 'get' uri.query = (uri.query.nil? ? '' : (uri.query + "&")) + URI.encode_www_form(request_params) response = Net::HTTP.get_response(uri) else response = Net::HTTP.post_form(uri, request_params) end rescue Exception => e puts e. return nil end if response.kind_of? Net::HTTPSuccess format == 'json' ? JSON.parse(response.body) : response.body else nil end end |
.type ⇒ Object
28 29 30 |
# File 'lib/oauth/provider.rb', line 28 def type self.to_s.split("::").last.downcase end |
Instance Method Details
#expired? ⇒ Boolean
23 24 25 |
# File 'lib/oauth/provider.rb', line 23 def expired? created_at + expires_in < Time.now + 10 end |