class ChefAPI::Multipart::Body

Public Class Methods

new(params = {}) click to toggle source
# File lib/chef-api/multipart.rb, line 9
def initialize(params = {})
  params.each do |key, value|
    if value.respond_to?(:read)
      parts << FilePart.new(key, value)
    else
      parts << ParamPart.new(key, value)
    end
  end

  parts << EndingPart.new
end

Public Instance Methods

content_length() click to toggle source
# File lib/chef-api/multipart.rb, line 29
def content_length
  parts.map(&:size).inject(:+)
end
content_type() click to toggle source
# File lib/chef-api/multipart.rb, line 25
def content_type
  "multipart/form-data; boundary=#{BOUNDARY}"
end
stream() click to toggle source
# File lib/chef-api/multipart.rb, line 21
def stream
  MultiIO.new(*parts.map(&:io))
end

Private Instance Methods

parts() click to toggle source
# File lib/chef-api/multipart.rb, line 35
def parts
  @parts ||= []
end