Sha256: 201445e5a914502468a11b1f63708fca7acf460428fb8055f7bb91d08b2f6f90
Contents?: true
Size: 916 Bytes
Versions: 3
Compression:
Stored size: 916 Bytes
Contents
module Praxis class MultipartPart attr_accessor :body attr_accessor :headers attr_accessor :filename def initialize(body, headers={}, filename: nil) @body = body @headers = headers @filename = filename end # Determine the content type of this response. # # @return [MediaTypeIdentifier] def content_type MediaTypeIdentifier.load(headers['Content-Type']).freeze end # Set the content type for this response. # @todo DRY this out (also used in Response) # # @return [String] # @param [String,MediaTypeIdentifier] identifier def content_type=(identifier) headers['Content-Type'] = MediaTypeIdentifier.load(identifier).to_s end def status @headers['Status'].to_i end def encode! case @body when Hash, Array @body = JSON.pretty_generate(@body) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
praxis-0.16.1 | lib/praxis/multipart/part.rb |
praxis-0.16.0 | lib/praxis/multipart/part.rb |
praxis-0.15.0 | lib/praxis/multipart/part.rb |