Module: Parts::Part

Included in:
EpiloguePart, FilePart, ParamPart
Defined in:
lib/parts.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.file?(value) ⇒ Boolean


18
19
20
# File 'lib/parts.rb', line 18

def self.file?(value)
  value.respond_to?(:content_type) && value.respond_to?(:original_filename)
end

.new(boundary, name, value, headers = {}) ⇒ Object


9
10
11
12
13
14
15
16
# File 'lib/parts.rb', line 9

def self.new(boundary, name, value, headers = {})
  headers ||= {} # avoid nil values
  if file?(value)
    FilePart.new(boundary, name, value, headers)
  else
    ParamPart.new(boundary, name, value, headers)
  end
end

Instance Method Details

#lengthObject


22
23
24
# File 'lib/parts.rb', line 22

def length
  @part.length
end

#to_ioObject


26
27
28
# File 'lib/parts.rb', line 26

def to_io
  @io
end