Class: Async::REST::Wrapper::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/async/rest/wrapper/generic.rb

Direct Known Subclasses

Form, JSON, URLEncoded

Defined Under Namespace

Classes: Unsupported

Instance Method Summary collapse

Instance Method Details

#parser_for(response) ⇒ Object



38
39
40
# File 'lib/async/rest/wrapper/generic.rb', line 38

def parser_for(response)
	return Unsupported
end

#prepare_request(payload, headers) ⇒ Body | nil

Returns an optional request body based on the given payload.

Parameters:

  • payload (Object)

    a request payload to send.

  • headers (Protocol::HTTP::Headers)

    the mutable HTTP headers for the request.

Returns:

  • (Body | nil)

    an optional request body based on the given payload.



28
29
# File 'lib/async/rest/wrapper/generic.rb', line 28

def prepare_request(payload, headers)
end

#process_response(request, response) ⇒ Object

Returns some application specific representation of the response.

Parameters:

  • request (Protocol::HTTP::Request)

    the request that was made.

  • response (Protocol::HTTP::Response)

    the response that was received.

Returns:

  • (Object)

    some application specific representation of the response.



34
35
36
# File 'lib/async/rest/wrapper/generic.rb', line 34

def process_response(request, response)
	wrap_response(response)
end

#wrap_response(response) ⇒ Object

Wrap the response body in the given klass.



43
44
45
46
47
48
49
# File 'lib/async/rest/wrapper/generic.rb', line 43

def wrap_response(response)
	if body = response.body
		response.body = parser_for(response).new(body)
	end
	
	return response
end