Module: RestClient::Payload
Defined Under Namespace
Classes: Base, Multipart, Streamed, UrlEncoded
Instance Method Summary (collapse)
Instance Method Details
- (Object) generate(params)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/restclient/payload.rb', line 9 def generate(params) if params.is_a?(String) Base.new(params) elsif params.respond_to?(:read) Streamed.new(params) elsif params if params.delete(:multipart) == true || has_file?(params) Multipart.new(params) else UrlEncoded.new(params) end else nil end end |
- (Boolean) has_file?(params)
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/restclient/payload.rb', line 25 def has_file?(params) params.any? do |_, v| case v when Hash has_file?(v) when Array has_file_array?(v) else v.respond_to?(:path) && v.respond_to?(:read) end end end |
- (Boolean) has_file_array?(params)
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/restclient/payload.rb', line 38 def has_file_array?(params) params.any? do |v| case v when Hash has_file?(v) when Array has_file_array?(v) else v.respond_to?(:path) && v.respond_to?(:read) end end end |