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 efb5549
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/http/form_data/multipart.rb
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
24 changes: 2 additions & 22 deletions lib/http/form_data/multipart/param.rb
Expand Up @@ -2,7 +2,6 @@

require "http/form_data/readable"
require "http/form_data/composite_io"
require "pry"

module HTTP
module FormData
Expand Down Expand Up @@ -40,11 +39,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 +56,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 efb5549

Please sign in to comment.