mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
more flixable type system that responds to #to_ary instead of Array
This commit is contained in:
parent
0805060d0c
commit
6bc1188b6b
2 changed files with 4 additions and 4 deletions
|
@ -27,8 +27,8 @@ module HTTParty
|
|||
param = ''
|
||||
stack = []
|
||||
|
||||
if value.is_a?(Array)
|
||||
param << value.map { |element| normalize_param("#{key}[]", element) }.join
|
||||
if value.respond_to?(:to_ary)
|
||||
param << value.to_ary.map { |element| normalize_param("#{key}[]", element) }.join
|
||||
elsif value.respond_to?(:to_hash)
|
||||
stack << [key,value.to_hash]
|
||||
else
|
||||
|
|
|
@ -18,8 +18,8 @@ module HTTParty
|
|||
Array(query).sort_by { |a| a[0].to_s }.map do |key, value|
|
||||
if value.nil?
|
||||
key.to_s
|
||||
elsif value.is_a?(Array)
|
||||
value.map {|v| "#{key}=#{URI.encode(v.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}"}
|
||||
elsif value.respond_to?(:to_ary)
|
||||
value.to_ary.map {|v| "#{key}=#{URI.encode(v.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}"}
|
||||
else
|
||||
HashConversions.to_params(key => value)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue