Parent

Methods

Files

Class/Module Index [+]

Quicksearch

Rack::Multipart::Generator

Public Class Methods

new(params, first = true) click to toggle source
# File lib/rack/multipart/generator.rb, line 4
def initialize(params, first = true)
  @params, @first = params, first

  if @first && !@params.is_a?(Hash)
    raise ArgumentError, "value must be a Hash"
  end
end

Public Instance Methods

dump() click to toggle source
# File lib/rack/multipart/generator.rb, line 12
def dump
  return nil if @first && !multipart?
  return flattened_params if !@first

  flattened_params.map do |name, file|
    if file.respond_to?(:original_filename)
      ::File.open(file.path, "rb") do |f|
        f.set_encoding(Encoding::BINARY) if f.respond_to?(:set_encoding)
        content_for_tempfile(f, file, name)
      end
    else
      content_for_other(file, name)
    end
  end.join + "--#{MULTIPART_BOUNDARY}--\r"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.