1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

explicit check for Hash during payload generation. At least one library (hashery) defines :read on Hash

Signed-off-by: Dmitri Dolguikh <dmitri@appliedlogic.ca>
This commit is contained in:
Dmitri Dolguikh 2012-11-15 19:42:46 +00:00
parent 616067e9bf
commit 352d0a8488

View file

@ -9,14 +9,14 @@ module RestClient
def generate(params) def generate(params)
if params.is_a?(String) if params.is_a?(String)
Base.new(params) Base.new(params)
elsif params.respond_to?(:read) elsif params and params.is_a?(Hash)
Streamed.new(params)
elsif params
if params.delete(:multipart) == true || has_file?(params) if params.delete(:multipart) == true || has_file?(params)
Multipart.new(params) Multipart.new(params)
else else
UrlEncoded.new(params) UrlEncoded.new(params)
end end
elsif params.respond_to?(:read)
Streamed.new(params)
else else
nil nil
end end