Class: Merb::Test::MultipartRequestHelper::FileParam

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-core/test/helpers/multipart_request_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, filename, content) ⇒ FileParam

Parameters

key<~to_s>

The parameter key.

filename<~to_s>

Name of the file for this parameter.

content<~to_s>

Content of the file for this parameter.



30
31
32
33
34
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 30

def initialize(key, filename, content)
  @key      = key
  @filename = filename
  @content  = content
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



24
25
26
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 24

def content
  @content
end

#filenameObject

Returns the value of attribute filename.



24
25
26
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 24

def filename
  @filename
end

#keyObject

Returns the value of attribute key.



24
25
26
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 24

def key
  @key
end

Instance Method Details

#to_multipartObject

Returns

String

The file parameter in a form suitable for a multipart request.



39
40
41
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 39

def to_multipart
  return %(Content-Disposition: form-data; name="#{key}"; filename="#{filename}"\r\n) + "Content-Type: #{MIME::Types.type_for(@filename).first}\r\n\r\n" + content + "\r\n"
end