Class: Wrest::Curl::PostMultipart

Inherits:
Request
  • Object
show all
Defined in:
lib/wrest/curl/post_multipart.rb

Instance Attribute Summary

Attributes inherited from Request

#auth_type, #body, #connection, #file_name, #follow_redirects, #follow_redirects_limit, #headers, #http_request, #multipart, #parameters, #password, #timeout, #uri, #username

Instance Method Summary collapse

Methods inherited from Request

#invoke

Constructor Details

#initialize(wrest_uri, parameters = {}, headers = {}, options = {}) ⇒ PostMultipart

Returns a new instance of PostMultipart



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/wrest/curl/post_multipart.rb', line 12

def initialize(wrest_uri, parameters = {}, headers = {}, options = {})
  parameters = parameters.symbolize_keys

  data = parameters[:data] ? {:data => parameters[:data]} : {:data => " "}
  file = parameters[:file].is_a?(File) ? {:file => parameters[:file].path} : {:file => parameters[:file]}

  options = options.merge({:data => data, :file => file, :multipart => true})
  parameters.delete(:data)
  parameters.delete(:file)
  super(
    wrest_uri,
    :post,
    parameters,
    options[:data],
    headers,
    options
  )
end