Method: Multiparty#initialize

Defined in:
lib/multiparty.rb

#initialize(options = {}) {|_self| ... } ⇒ Multiparty

Multiparty.new("my-boundary") Multiparty.new(:boundary => "my-boundary")

Yields:

  • (_self)

Yield Parameters:

  • _self (Multiparty)

    the object that the method was called on



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/multiparty.rb', line 9

def initialize(options = {})
  case options
  when Hash
    @boundary = options[:boundary]
    @content_type = options[:content_type]
  when String 
    @boundary = options
  end
 
  @parts = {}
  @content_type ||= "multipart/form-data"
  @boundary ||= "multiparty-boundary-#{rand(1000000000)}"

  yield self if block_given?
end