Class: T::Request
- Inherits:
-
Object
- Object
- T::Request
- Defined in:
- lib/tinternet/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#verb ⇒ Object
Returns the value of attribute verb.
Instance Method Summary collapse
- #auth_header_name ⇒ Object
- #authorize(header_value) ⇒ Object
- #authorized? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(opts = {}) ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 |
# File 'lib/tinternet/request.rb', line 5 def initialize(opts = {}) self.verb = opts[:verb] || :get self.uri = opts[:uri] self.headers = opts[:headers] || {} self.body = opts[:body] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/tinternet/request.rb', line 3 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
3 4 5 |
# File 'lib/tinternet/request.rb', line 3 def headers @headers end |
#uri ⇒ Object
Returns the value of attribute uri.
3 4 5 |
# File 'lib/tinternet/request.rb', line 3 def uri @uri end |
#verb ⇒ Object
Returns the value of attribute verb.
3 4 5 |
# File 'lib/tinternet/request.rb', line 3 def verb @verb end |
Instance Method Details
#auth_header_name ⇒ Object
20 |
# File 'lib/tinternet/request.rb', line 20 def auth_header_name; "Authorization"; end |
#authorize(header_value) ⇒ Object
12 13 14 |
# File 'lib/tinternet/request.rb', line 12 def (header_value) headers[auth_header_name] = header_value end |
#authorized? ⇒ Boolean
16 17 18 |
# File 'lib/tinternet/request.rb', line 16 def headers.include? auth_header_name end |