class Faraday::ParamPart

Multipart value used to POST data with a content type.

Attributes

content_id[R]

The value's content ID, if given.

@return [String, nil]

content_type[R]

The value's content type.

@return [String]

value[R]

The content to upload.

@return [String]

Public Class Methods

new(value, content_type, content_id = nil) click to toggle source

@param value [String] Uploaded content as a String. @param content_type [String] String content type of the value. @param content_id [String] Optional String of this value's Content-ID.

@return [Faraday::ParamPart]

# File lib/faraday/param_part.rb, line 11
def initialize(value, content_type, content_id = nil)
  @value = value
  @content_type = content_type
  @content_id = content_id
end

Public Instance Methods

headers() click to toggle source

Returns a Hash of String key/value pairs.

@return [Hash]

# File lib/faraday/param_part.rb, line 31
def headers
  {
    'Content-Type' => content_type,
    'Content-ID' => content_id
  }
end
to_part(boundary, key) click to toggle source

Converts this value to a form part.

@param boundary [String] String multipart boundary that must not exist in

the content exactly.

@param key [String] String key name for this value.

@return [Faraday::Parts::Part]

# File lib/faraday/param_part.rb, line 24
def to_part(boundary, key)
  Faraday::Parts::Part.new(boundary, key, value, headers)
end