Module: Multipartable

### Home Classes Methods

### In Files

- lib/multipartable.rb

### Methods

- ::new

### Class/Module Index

Quicksearch

- Net
- Net::HTTP
- Net::HTTP::Post
- Net::HTTP::Post::Multipart
- Net::HTTP::Put
- Net::HTTP::Put::Multipart
- Parts
- Parts::EpiloguePart
- Parts::FilePart
- Parts::ParamPart
- CompositeReadIO
- MultipartPost
- Multipartable
- UploadIO

No matching classes.

# Multipartable

### Constants

DEFAULT_BOUNDARY

### Public Class Methods

new(path, params, headers={}, boundary = DEFAULT_BOUNDARY) click to toggle source

    # File lib/multipartable.rb, line 10
    def initialize(path, params, headers={}, boundary = DEFAULT_BOUNDARY)
      headers = headers.clone # don't want to modify the original variable
      parts_headers = headers.delete(:parts) || {}
      super(path, headers)
      parts = params.map do |k,v|
        case v
        when Array
          v.map {|item| Parts::Part.new(boundary, k, item, parts_headers[k]) }
        else
          Parts::Part.new(boundary, k, v, parts_headers[k])
        end
      end.flatten
      parts << Parts::EpiloguePart.new(boundary)
      ios = parts.map {|p| p.to_io }
      self.set_content_type(headers["Content-Type"] || "multipart/form-data",
                            { "boundary" => boundary })
      self.content_length = parts.inject(0) {|sum,i| sum + i.length }
      self.body_stream = CompositeReadIO.new(*ios)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.