Class: RestMan::Payload::Multipart
- Inherits:
-
Base
- Object
- Base
- RestMan::Payload::Multipart
show all
- Includes:
- ActiveMethod
- Defined in:
- lib/restman/payload/multipart.rb,
lib/restman/payload/multipart/write_content_disposition.rb
Defined Under Namespace
Classes: WriteContentDisposition
Instance Method Summary
collapse
Methods inherited from Base
#closed?, #initialize, #read, #short_inspect, #size, #to_s, #to_s_inspect
Instance Method Details
#boundary ⇒ Object
40
41
42
|
# File 'lib/restman/payload/multipart.rb', line 40
def boundary
@boundary ||= generate_boundary
end
|
#build_stream(params) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/restman/payload/multipart.rb', line 17
def build_stream(params)
@stream = Tempfile.new('rest-man.multipart.')
@stream.binmode
flatten(params).each do |name, value|
write_content_disposition(@stream, name, value, boundary)
end
@stream.write "--#{boundary}--\r\n"
@stream.seek(0)
end
|
#close ⇒ Object
36
37
38
|
# File 'lib/restman/payload/multipart.rb', line 36
def close
@stream.close!
end
|
#flatten(params) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/restman/payload/multipart.rb', line 27
def flatten(params)
case params
when Hash, ParamsArray
Utils.flatten_params(params)
else
params
end
end
|
13
14
15
|
# File 'lib/restman/payload/multipart.rb', line 13
def
super.merge({'Content-Type' => %Q{multipart/form-data; boundary=#{boundary}}})
end
|