Saves the params in an array of multipart params as Param and FileParam objects.
params | 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 61: def push_params(params, prefix = nil) 62: params.sort_by {|k| k.to_s}.each do |key, value| 63: param_key = prefix.nil? ? key : "#{prefix}[#{key}]" 64: if value.respond_to?(:read) 65: @multipart_params << FileParam.new(param_key, value.path, value.read) 66: else 67: if value.is_a?(Hash) || value.is_a?(Mash) 68: push_params(value, param_key) 69: elsif value.is_a?(Array) 70: value.each { |v| push_params(v, "#{param_key}[]") } 71: else 72: @multipart_params << Param.new(param_key, value) 73: end 74: end 75: end 76: end
Array[String, String] | The query and the content type. |
# File lib/merb-core/test/helpers/multipart_request_helper.rb, line 80 80: def to_multipart 81: query = @multipart_params.collect { |param| "--" + BOUNDARY + "\r\n" + param.to_multipart }.join("") + "--" + BOUNDARY + "--" 82: return query, CONTENT_TYPE 83: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.