Class: Webrat::MerbAdapter
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#delete(url, data, headers = nil) ⇒ Object
-
#do_request(url, data, headers, method) ⇒ Object
-
#get(url, data, headers = nil) ⇒ Object
-
#initialize(context = nil) ⇒ MerbAdapter
constructor
A new instance of MerbAdapter.
-
#post(url, data, headers = nil) ⇒ Object
-
#put(url, data, headers = nil) ⇒ Object
-
#response_body ⇒ Object
-
#response_code ⇒ Object
#multipart_post, #multipart_put, #multipart_request
Constructor Details
#initialize(context = nil) ⇒ MerbAdapter
Returns a new instance of MerbAdapter.
15
|
# File 'lib/webrat/merb_adapter.rb', line 15
def initialize(context=nil); end
|
Instance Attribute Details
Returns the value of attribute response.
13
14
15
|
# File 'lib/webrat/merb_adapter.rb', line 13
def response
@response
end
|
Instance Method Details
#delete(url, data, headers = nil) ⇒ Object
29
30
31
|
# File 'lib/webrat/merb_adapter.rb', line 29
def delete(url, data, = nil)
do_request(url, data, , "DELETE")
end
|
#do_request(url, data, headers, method) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/webrat/merb_adapter.rb', line 41
def do_request(url, data, , method)
if method == "POST" && has_file?(data)
@response = multipart_post(url, data, :headers => )
elsif method == "PUT" && has_file?(data)
@response = multipart_put(url, data, :headers => )
else
@response = request(url,
:params => (data && data.any?) ? data : nil,
:headers => ,
:method => method)
end
end
|
#get(url, data, headers = nil) ⇒ Object
17
18
19
|
# File 'lib/webrat/merb_adapter.rb', line 17
def get(url, data, = nil)
do_request(url, data, , "GET")
end
|
#post(url, data, headers = nil) ⇒ Object
21
22
23
|
# File 'lib/webrat/merb_adapter.rb', line 21
def post(url, data, = nil)
do_request(url, data, , "POST")
end
|
#put(url, data, headers = nil) ⇒ Object
25
26
27
|
# File 'lib/webrat/merb_adapter.rb', line 25
def put(url, data, = nil)
do_request(url, data, , "PUT")
end
|
#response_body ⇒ Object
33
34
35
|
# File 'lib/webrat/merb_adapter.rb', line 33
def response_body
@response.body.to_s
end
|
#response_code ⇒ Object
37
38
39
|
# File 'lib/webrat/merb_adapter.rb', line 37
def response_code
@response.status
end
|