Class: EventMachine::AblyHttpRequest::Middleware::OAuth2
- Inherits:
-
Object
- Object
- EventMachine::AblyHttpRequest::Middleware::OAuth2
- Includes:
- EM::AblyHttpRequest::HttpEncoding
- Defined in:
- lib/em-http/middleware/oauth2.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ OAuth2
constructor
A new instance of OAuth2.
- #request(client, head, body) ⇒ Object
- #update_uri!(uri) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ OAuth2
Returns a new instance of OAuth2.
8 9 10 |
# File 'lib/em-http/middleware/oauth2.rb', line 8 def initialize(opts={}) self.access_token = opts[:access_token] or raise "No :access_token provided" end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/em-http/middleware/oauth2.rb', line 6 def access_token @access_token end |
Instance Method Details
#request(client, head, body) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/em-http/middleware/oauth2.rb', line 12 def request(client, head, body) uri = client.req.uri.dup update_uri! uri client.req.set_uri uri [head, body] end |
#update_uri!(uri) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/em-http/middleware/oauth2.rb', line 20 def update_uri!(uri) if uri.query.nil? uri.query = encode_param(:access_token, access_token) else uri.query += "&#{encode_param(:access_token, access_token)}" end end |