Class: Xio::HTTP
- Inherits:
-
Object
show all
- Includes:
- Serializer
- Defined in:
- lib/xio/http.rb,
lib/xio/http/net_http.rb,
lib/xio/http/typhoeus.rb
Defined Under Namespace
Classes: NetHTTP, Typhoeus
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Serializer
#decode, #encode, included
Constructor Details
#initialize(method, url, options = {}) ⇒ HTTP
Returns a new instance of HTTP.
19
20
21
22
23
|
# File 'lib/xio/http.rb', line 19
def initialize(method, url, options={})
self.method = method
self.url = url
self.options = options
end
|
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
9
10
11
|
# File 'lib/xio/http.rb', line 9
def default_options
@default_options
end
|
.http_backend ⇒ Object
Returns the value of attribute http_backend.
9
10
11
|
# File 'lib/xio/http.rb', line 9
def http_backend
@http_backend
end
|
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
6
7
8
|
# File 'lib/xio/http.rb', line 6
def method
@method
end
|
#options ⇒ Object
Returns the value of attribute options.
6
7
8
|
# File 'lib/xio/http.rb', line 6
def options
@options
end
|
#url ⇒ Object
Returns the value of attribute url.
6
7
8
|
# File 'lib/xio/http.rb', line 6
def url
@url
end
|
Class Method Details
.delete(url, options = {}) ⇒ Object
37
38
39
|
# File 'lib/xio/http.rb', line 37
def self.delete(url, options={})
new(:delete, url, options).perform_method
end
|
.get(url, options = {}) ⇒ Object
33
34
35
|
# File 'lib/xio/http.rb', line 33
def self.get(url, options={})
new(:get, url, options).perform_method
end
|
.post(url, body, options = {}) ⇒ Object
25
26
27
|
# File 'lib/xio/http.rb', line 25
def self.post(url, body, options={})
new(:post, url, options.merge(:body => body)).perform_method
end
|
.put(url, body, options = {}) ⇒ Object
29
30
31
|
# File 'lib/xio/http.rb', line 29
def self.put(url, body, options={})
new(:put, url, options.merge(:body => body)).perform_method
end
|
Instance Method Details
#default_options ⇒ Object
72
73
74
|
# File 'lib/xio/http.rb', line 72
def default_options
self.class.default_options
end
|
#http_backend ⇒ Object
68
69
70
|
# File 'lib/xio/http.rb', line 68
def http_backend
self.class.http_backend
end
|
#inspect ⇒ Object
76
77
78
|
# File 'lib/xio/http.rb', line 76
def inspect
"#{method.to_s.upcase} #{url}\nOptions: " + options.inspect
end
|
41
42
43
44
45
|
# File 'lib/xio/http.rb', line 41
def perform_method
process(http_backend.send(method, url, options))
rescue StandardError => e
raise HTTPError.new(e)
end
|