Class to handle connections to remote web services. This class is used by ActiveResource::Base to interface with REST services.

Methods
A
D
G
H
N
P
R
S
T
U
Constants
HTTP_FORMAT_HEADER_NAMES = { :get => 'Accept', :put => 'Content-Type', :post => 'Content-Type', :delete => 'Accept', :head => 'Accept' }
Attributes
[R] site
[R] user
[R] password
[R] auth_type
[R] timeout
[R] proxy
[R] ssl_options
[RW] format
Class Public methods
new(site, format = ActiveResource::Formats::JsonFormat)

The site parameter is required and will set the site attribute to the URI for the remote resource service.

    # File activeresource/lib/active_resource/connection.rb, line 33
33:     def initialize(site, format = ActiveResource::Formats::JsonFormat)
34:       raise ArgumentError, 'Missing site URI' unless site
35:       @user = @password = nil
36:       self.site = site
37:       self.format = format
38:     end
requests()
    # File activeresource/lib/active_resource/connection.rb, line 26
26:       def requests
27:         @@requests ||= []
28:       end
Instance Public methods
auth_type=(auth_type)

Sets the auth type for remote service.

    # File activeresource/lib/active_resource/connection.rb, line 63
63:     def auth_type=(auth_type)
64:       @auth_type = legitimize_auth_type(auth_type)
65:     end
delete(path, headers = {})

Executes a DELETE request (see HTTP protocol documentation if unfamiliar). Used to delete resources.

    # File activeresource/lib/active_resource/connection.rb, line 85
85:     def delete(path, headers = {})
86:       with_auth { request(:delete, path, build_request_headers(headers, :delete, self.site.merge(path))) }
87:     end
get(path, headers = {})

Executes a GET request. Used to get (find) resources.

    # File activeresource/lib/active_resource/connection.rb, line 79
79:     def get(path, headers = {})
80:       with_auth { request(:get, path, build_request_headers(headers, :get, self.site.merge(path))) }
81:     end
head(path, headers = {})

Executes a HEAD request. Used to obtain meta-information about resources, such as whether they exist and their size (via response headers).

     # File activeresource/lib/active_resource/connection.rb, line 103
103:     def head(path, headers = {})
104:       with_auth { request(:head, path, build_request_headers(headers, :head, self.site.merge(path))) }
105:     end
password=(password)

Sets the password for remote service.

    # File activeresource/lib/active_resource/connection.rb, line 58
58:     def password=(password)
59:       @password = password
60:     end
post(path, body = '', headers = {})

Executes a POST request. Used to create new resources.

    # File activeresource/lib/active_resource/connection.rb, line 97
97:     def post(path, body = '', headers = {})
98:       with_auth { request(:post, path, body.to_s, build_request_headers(headers, :post, self.site.merge(path))) }
99:     end
proxy=(proxy)

Set the proxy for remote service.

    # File activeresource/lib/active_resource/connection.rb, line 48
48:     def proxy=(proxy)
49:       @proxy = proxy.is_a?(URI) ? proxy : URI.parser.parse(proxy)
50:     end
put(path, body = '', headers = {})

Executes a PUT request (see HTTP protocol documentation if unfamiliar). Used to update resources.

    # File activeresource/lib/active_resource/connection.rb, line 91
91:     def put(path, body = '', headers = {})
92:       with_auth { request(:put, path, body.to_s, build_request_headers(headers, :put, self.site.merge(path))) }
93:     end
site=(site)

Set URI for remote service.

    # File activeresource/lib/active_resource/connection.rb, line 41
41:     def site=(site)
42:       @site = site.is_a?(URI) ? site : URI.parser.parse(site)
43:       @user = URI.parser.unescape(@site.user) if @site.user
44:       @password = URI.parser.unescape(@site.password) if @site.password
45:     end
ssl_options=(opts={})

Hash of options applied to Net::HTTP instance when site protocol is ‘https’.

    # File activeresource/lib/active_resource/connection.rb, line 73
73:     def ssl_options=(opts={})
74:       @ssl_options = opts
75:     end
timeout=(timeout)

Sets the number of seconds after which HTTP requests to the remote service should time out.

    # File activeresource/lib/active_resource/connection.rb, line 68
68:     def timeout=(timeout)
69:       @timeout = timeout
70:     end
user=(user)

Sets the user for remote service.

    # File activeresource/lib/active_resource/connection.rb, line 53
53:     def user=(user)
54:       @user = user
55:     end