diff --git a/.gitignore b/.gitignore index 40c6683..75a08dc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Gemfile.lock .yardoc doc coverage +.idea diff --git a/lib/ethon/easy/queryable.rb b/lib/ethon/easy/queryable.rb index cd59828..d03e7f1 100644 --- a/lib/ethon/easy/queryable.rb +++ b/lib/ethon/easy/queryable.rb @@ -129,16 +129,30 @@ def encode_rack_array_pairs(h, prefix, pairs) end end - def encode_multi_array_pairs(h, prefix, pairs) - h.each_with_index do |v, i| - key = prefix - pairs_for(v, key, pairs) + def encode_multi_array_pairs(h, prefix, pairs) + h.each_with_index do |v, i| + key = prefix + pairs_for(v, key, pairs) + end end - end def pairs_for(v, key, pairs) case v - when Hash, Array + when Hash + + # If the hash element contains an entry named "filehandle" then we + # have a file with a potentially specified filename and mimetype. + # handle this special case. + if !v[:filehandle].nil? and v[:filehandle].is_a? File + fileinfo = file_info(v[:filehandle]) + + if !v[:filename].nil? then fileinfo[0] = v[:filename] end + if !v[:mimetype].nil? then fileinfo[1] = v[:mimetype] end + pairs << [key, fileinfo] + else + recursively_generate_pairs(v, key, pairs) + end + when Array recursively_generate_pairs(v, key, pairs) when File, Tempfile pairs << [key, file_info(v)]