class Async::REST::Wrapper::JSON

Constants

APPLICATION_JSON
APPLICATION_JSON_STREAM

Attributes

content_type[R]

Public Class Methods

new(content_type = APPLICATION_JSON) click to toggle source
# File lib/async/rest/wrapper/json.rb, line 37
def initialize(content_type = APPLICATION_JSON)
        @content_type = content_type
end

Public Instance Methods

parser_for(response) click to toggle source
# File lib/async/rest/wrapper/json.rb, line 65
def parser_for(response)
        if content_type = response.headers['content-type']
                if content_type.start_with? @content_type
                        return Parser
                end
        end
        
        return super
end
prepare_request(payload, headers) click to toggle source
# File lib/async/rest/wrapper/json.rb, line 47
def prepare_request(payload, headers)
        headers['accept'] ||= @content_type
        
        if payload
                headers['content-type'] = @content_type
                
                HTTP::Body::Buffered.new([
                        ::JSON.dump(payload)
                ])
        end
end
split(*arguments) click to toggle source
# File lib/async/rest/wrapper/json.rb, line 43
def split(*arguments)
        @content_type.split
end