Skip to content

Commit efb5549

Browse files
author
Matt Kelly
committed
Kill redudant coercion method
1 parent 2631b36 commit efb5549

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

lib/http/form_data/multipart.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def tail
5454
end
5555

5656
def parts(data)
57-
return Param.coerce_array_of_pairs data if data.is_a?(Array)
57+
return Param.coerce data if data.is_a?(Array)
5858
Param.coerce FormData.ensure_hash data
5959
end
6060
end

lib/http/form_data/multipart/param.rb

+2-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
require "http/form_data/readable"
44
require "http/form_data/composite_io"
5-
require "pry"
65

76
module HTTP
87
module FormData
@@ -40,11 +39,11 @@ def initialize(name, value)
4039
@io = CompositeIO.new [header, @part, footer]
4140
end
4241

43-
# Flattens given `data` Hash into an array of `Param`'s.
42+
# Flattens given `data` Hash or Array into an array of `Param`'s.
4443
# Nested array are unwinded.
4544
# Behavior is similar to `URL.encode_www_form`.
4645
#
47-
# @param [Hash] data
46+
# @param [Array || Hash] data
4847
# @return [Array<FormData::MultiPart::Param>]
4948
def self.coerce(data)
5049
params = []
@@ -57,25 +56,6 @@ def self.coerce(data)
5756
params
5857
end
5958

60-
# Flattens given Array of `data` Array pairs into an array of `Param`'s.
61-
# Nested array are unwinded.
62-
# Behavior is similar to `URL.encode_www_form`.
63-
#
64-
# @param [Array] data
65-
# @return [Array<FormData::MultiPart::Param>]
66-
def self.coerce_array_of_pairs(data)
67-
params = []
68-
69-
data.each do |pair|
70-
name, values = pair
71-
Array(values).each do |value|
72-
params << new(name, value)
73-
end
74-
end
75-
76-
params
77-
end
78-
7959
private
8060

8161
def header

0 commit comments

Comments
 (0)