Sha256: 467e6582cf176e1e01557f4bc3a0e84d61a6e4c5153a676be3e32302828bf31e

Contents?: true

Size: 1.33 KB

Versions: 70

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Faraday
  # Multipart value used to POST data with a content type.
  class ParamPart
    # @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]
    def initialize(value, content_type, content_id = nil)
      @value = value
      @content_type = content_type
      @content_id = content_id
    end

    # 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]
    def to_part(boundary, key)
      Faraday::Parts::Part.new(boundary, key, value, headers)
    end

    # Returns a Hash of String key/value pairs.
    #
    # @return [Hash]
    def headers
      {
        'Content-Type' => content_type,
        'Content-ID' => content_id
      }
    end

    # The content to upload.
    #
    # @return [String]
    attr_reader :value

    # The value's content type.
    #
    # @return [String]
    attr_reader :content_type

    # The value's content ID, if given.
    #
    # @return [String, nil]
    attr_reader :content_id
  end
end

Version data entries

70 entries across 58 versions & 13 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/faraday-1.2.0/lib/faraday/param_part.rb
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.0.1/lib/faraday/param_part.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/param_part.rb
faraday-2.0.0.alpha.pre.4 lib/faraday/param_part.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/param_part.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/param_part.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.8.0/lib/faraday/param_part.rb
faraday-2.0.0.alpha.pre.3 lib/faraday/param_part.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/param_part.rb
faraday-2.0.0.alpha.pre.2 lib/faraday/param_part.rb
faraday-2.0.0.alpha.pre.1 lib/faraday/param_part.rb
faraday-1.8.0 lib/faraday/param_part.rb
faraday-1.7.2 lib/faraday/param_part.rb
faraday-1.7.1 lib/faraday/param_part.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/faraday-1.7.0/lib/faraday/param_part.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/param_part.rb
mx-platform-ruby-0.4.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/param_part.rb
mx-platform-ruby-0.3.2 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/param_part.rb
mx-platform-ruby-0.3.1 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/param_part.rb
faraday-1.7.0 lib/faraday/param_part.rb