Skip to content

Commit

Permalink
Kill redudant coercion method
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Kelly committed May 28, 2021
1 parent 2631b36 commit 14c6985
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/http/form_data/multipart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 2 additions & 21 deletions lib/http/form_data/multipart/param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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<FormData::MultiPart::Param>]
def self.coerce(data)
params = []
Expand All @@ -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<FormData::MultiPart::Param>]
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
Expand Down

0 comments on commit 14c6985

Please sign in to comment.