Parent

Class Index [+]

Quicksearch

Merb::Test::MultipartRequestHelper::Post

Constants

BOUNDARY
CONTENT_TYPE

Public Class Methods

new(params = {}) click to toggle source

Parameters

params

Optional params for the controller.

    # File lib/merb-core/test/helpers/multipart_request_helper.rb, line 50
50:     def initialize(params = {})
51:       @multipart_params = []
52:       push_params(params)
53:     end

Public Instance Methods

push_params(params, prefix = nil) click to toggle source

Saves the params in an array of multipart params as Param and FileParam objects.

Parameters

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
to_multipart() click to toggle source

Returns

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.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.