Class: URL::RequestHandler
- Inherits:
-
Object
- Object
- URL::RequestHandler
- Defined in:
- lib/url/handlers.rb
Overview
Handlers for making requests for the URL. To create your own you need to follow the following conventions:
-
You must define the get, post, and delete instance methods
-
These methods should return a Response object
To create a Response object:
hsh = {
:code => resp.code,
:time => resp.time,
:body => resp.body,
:response => resp,
:url => url.to_s
}
Response.new(hsh)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete(args = {}) ⇒ Object
- #get(args = {}) ⇒ Object
-
#initialize(url) ⇒ RequestHandler
constructor
A new instance of RequestHandler.
- #post(args = {}) ⇒ Object
- #put(args = {}) ⇒ Object
Constructor Details
#initialize(url) ⇒ RequestHandler
Returns a new instance of RequestHandler.
18 19 20 |
# File 'lib/url/handlers.rb', line 18 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
17 18 19 |
# File 'lib/url/handlers.rb', line 17 def url @url end |
Instance Method Details
#delete(args = {}) ⇒ Object
30 31 32 |
# File 'lib/url/handlers.rb', line 30 def delete(args={}) raise Exception, "You need to implement #{self.class}#delete" end |
#get(args = {}) ⇒ Object
22 23 24 |
# File 'lib/url/handlers.rb', line 22 def get(args={}) raise Exception, "You need to implement #{self.class}#get" end |
#post(args = {}) ⇒ Object
26 27 28 |
# File 'lib/url/handlers.rb', line 26 def post(args={}) raise Exception, "You need to implement #{self.class}#post" end |
#put(args = {}) ⇒ Object
34 35 36 |
# File 'lib/url/handlers.rb', line 34 def put(args={}) raise Exception, "You need to implement #{self.class}#put" end |