class Async::REST::Wrapper::Form

Constants

DEFAULT_CONTENT_TYPES

Public Class Methods

new(content_types = DEFAULT_CONTENT_TYPES) click to toggle source
# File lib/async/rest/wrapper/form.rb, line 35
def initialize(content_types = DEFAULT_CONTENT_TYPES)
        @content_types = content_types
end

Public Instance Methods

parser_for(response) click to toggle source
Calls superclass method
# File lib/async/rest/wrapper/form.rb, line 53
def parser_for(response)
        if content_type = response.headers['content-type']
                if parser = @content_types[content_type]
                        return parser
                end
        end
        
        return super
end
prepare_request(payload, headers) click to toggle source
# File lib/async/rest/wrapper/form.rb, line 39
def prepare_request(payload, headers)
        @content_types.each_key do |key|
                headers.add('accept', key)
        end
        
        if payload
                headers['content-type'] = URLEncoded::APPLICATION_FORM_URLENCODED
                
                ::Protocol::HTTP::Body::Buffered.new([
                        ::Protocol::HTTP::URL.encode(payload)
                ])
        end
end