Object
Duplicate of ActiveResource::HttpMock method
Class to handle connections to remote web services. This class is used by ActiveResource::Base to interface with REST services.
The site parameter is required and will set the site attribute to the URI for the remote resource service.
# File lib/active_resource/persistent_connection.rb, line 49 def initialize(site, format = ActiveResource::Formats::XmlFormat) raise ArgumentError, 'Missing site URI' unless site @user = @password = nil @uri_parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI self.site = site self.format = format end
Sets the auth type for remote service.
# File lib/active_resource/persistent_connection.rb, line 80 def auth_type=(auth_type) @auth_type = legitimize_auth_type(auth_type) end
Name for this group of requests, passed to Net::HTTP::Persistent
# File lib/active_resource/persistent_connection.rb, line 101 def connection_name=(name) @connection_name = name end
Sets the debug output stream for HTTP requests
# File lib/active_resource/persistent_connection.rb, line 85 def debug_output=(debug_output) @debug_output = debug_output end
Executes a DELETE request (see HTTP protocol documentation if unfamiliar). Used to delete resources.
# File lib/active_resource/persistent_connection.rb, line 114 def delete(path, headers = {}) with_auth { request(:delete, path, build_request_headers(headers, :delete, self.site.merge(path))) } end
Executes a GET request. Used to get (find) resources. Note; removed format.decode wrapper and .get method call
# File lib/active_resource/persistent_connection.rb, line 108 def get(path, headers = {}) with_auth { request(:get, path, build_request_headers(headers, :get, self.site.merge(path))) } end
Executes a HEAD request. Used to obtain meta-information about resources, such as whether they exist and their size (via response headers).
# File lib/active_resource/persistent_connection.rb, line 138 def head(path, headers = {}) with_auth { request(:head, path, build_request_headers(headers, :head, self.site.merge(path))) } end
Sets the password for remote service.
# File lib/active_resource/persistent_connection.rb, line 75 def password=(password) @password = password end
Executes a PATCH request. Used to create new resources.
# File lib/active_resource/persistent_connection.rb, line 132 def patch(path, body = '', headers = {}) with_auth { request(:patch, path, body.to_s, build_request_headers(headers, :patch, self.site.merge(path))) } end
Executes a POST request. Used to create new resources.
# File lib/active_resource/persistent_connection.rb, line 126 def post(path, body = '', headers = {}) with_auth { request(:post, path, body.to_s, build_request_headers(headers, :post, self.site.merge(path))) } end
Set the proxy for remote service.
# File lib/active_resource/persistent_connection.rb, line 65 def proxy=(proxy) @proxy = proxy.is_a?(URI) ? proxy : @uri_parser.parse(proxy) end
Executes a PUT request (see HTTP protocol documentation if unfamiliar). Used to update resources.
# File lib/active_resource/persistent_connection.rb, line 120 def put(path, body = '', headers = {}) with_auth { request(:put, path, body.to_s, build_request_headers(headers, :put, self.site.merge(path))) } end
Set URI for remote service.
# File lib/active_resource/persistent_connection.rb, line 58 def site=(site) @site = site.is_a?(URI) ? site : @uri_parser.parse(site) @user = @uri_parser.unescape(@site.user) if @site.user @password = @uri_parser.unescape(@site.password) if @site.password end
Generated with the Darkfish Rdoc Generator 2.