Module: Multipart::Post::Parts::Part

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.file?(value) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/multipart/post/parts.rb', line 37

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

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



28
29
30
31
32
33
34
35
# File 'lib/multipart/post/parts.rb', line 28

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



41
42
43
# File 'lib/multipart/post/parts.rb', line 41

def length
  @part.length
end

#to_ioObject



45
46
47
# File 'lib/multipart/post/parts.rb', line 45

def to_io
  @io
end