Saves the params in an array of multipart params as Param and FileParam objects.
params<Hash> |
The params to add to the multipart params. |
prefix<~to_s> |
An optional prefix for the request string keys. |
# File lib/merb-core/test/helpers/multipart_request_helper.rb, line 61 def push_params(params, prefix = nil) params.sort_by {|k| k.to_s}.each do |key, value| param_key = prefix.nil? ? key : "#{prefix}[#{key}]" if value.respond_to?(:read) @multipart_params << FileParam.new(param_key, value.path, value.read) else if value.is_a?(Hash) || value.is_a?(Mash) push_params(value, param_key) elsif value.is_a?(Array) value.each { |v| push_params(v, "#{param_key}[]") } else @multipart_params << Param.new(param_key, value) end end end end
Array[String, String] |
The query and the content type. |
# File lib/merb-core/test/helpers/multipart_request_helper.rb, line 80 def to_multipart query = @multipart_params.collect { |param| "--" + BOUNDARY + "\r\n" + param.to_multipart }.join("") + "--" + BOUNDARY + "--" return query, CONTENT_TYPE end
Generated with the Darkfish Rdoc Generator 2.