diff --git a/lib/http/form_data/multipart.rb b/lib/http/form_data/multipart.rb index b7c387e..ed10c56 100644 --- a/lib/http/form_data/multipart.rb +++ b/lib/http/form_data/multipart.rb @@ -54,7 +54,7 @@ def tail end def parts(data) - return Param.coerce_array_of_pairs data if data.is_a?(Array) + return Param.coerce data if data.is_a?(Array) Param.coerce FormData.ensure_hash data end end diff --git a/lib/http/form_data/multipart/param.rb b/lib/http/form_data/multipart/param.rb index 0b19b22..b96c574 100644 --- a/lib/http/form_data/multipart/param.rb +++ b/lib/http/form_data/multipart/param.rb @@ -40,11 +40,11 @@ def initialize(name, value) @io = CompositeIO.new [header, @part, footer] end - # Flattens given `data` Hash into an array of `Param`'s. + # Flattens given `data` Hash or Array into an array of `Param`'s. # Nested array are unwinded. # Behavior is similar to `URL.encode_www_form`. # - # @param [Hash] data + # @param [Array || Hash] data # @return [Array] def self.coerce(data) params = [] @@ -57,25 +57,6 @@ def self.coerce(data) params end - # Flattens given Array of `data` Array pairs into an array of `Param`'s. - # Nested array are unwinded. - # Behavior is similar to `URL.encode_www_form`. - # - # @param [Array] data - # @return [Array] - def self.coerce_array_of_pairs(data) - params = [] - - data.each do |pair| - name, values = pair - Array(values).each do |value| - params << new(name, value) - end - end - - params - end - private def header