Class: URL::RequestHandler

Inherits:
Object
  • Object
show all
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:

  1. You must define the get, post, and delete instance methods

  2. 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

NetHandler, TyHandler

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#urlObject (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

Raises:

  • (Exception)


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

Raises:

  • (Exception)


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

Raises:

  • (Exception)


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

Raises:

  • (Exception)


34
35
36
# File 'lib/url/handlers.rb', line 34

def put(args={})
  raise Exception, "You need to implement #{self.class}#put"
end