Class: Weary::Request
- Inherits:
-
Object
- Object
- Weary::Request
- Defined in:
- lib/weary/request.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(url, http_verb = :get, options = {}) ⇒ Request
constructor
A new instance of Request.
- #method ⇒ Object
- #method=(http_verb) ⇒ Object
- #perform ⇒ Object (also: #make)
Constructor Details
#initialize(url, http_verb = :get, options = {}) ⇒ Request
Returns a new instance of Request.
7 8 9 10 11 |
# File 'lib/weary/request.rb', line 7 def initialize(url, http_verb= :get, ={}) self.method = http_verb self.uri = url self. = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/weary/request.rb', line 5 def end |
#uri ⇒ Object
Returns the value of attribute uri.
4 5 6 |
# File 'lib/weary/request.rb', line 4 def uri @uri end |
Instance Method Details
#method ⇒ Object
34 35 36 |
# File 'lib/weary/request.rb', line 34 def method @http_verb end |
#method=(http_verb) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/weary/request.rb', line 17 def method=(http_verb) @http_verb = case http_verb when *Methods[:get] :get when *Methods[:post] :post when *Methods[:put] :put when *Methods[:delete] :delete when *Methods[:head] :head else raise ArgumentError, "Only GET, POST, PUT, DELETE, and HEAD methods are supported" end end |
#perform ⇒ Object Also known as: make
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/weary/request.rb', line 38 def perform req = http.request(request) response = Response.new(req, @http_verb) unless [:no_follow] if response.redirected? response.follow_redirect else response end else response end end |