Class: Faraday::Parts::ParamPart

Inherits:
Object
  • Object
show all
Defined in:
lib/restforce/patches/parts.rb

Instance Method Summary collapse

Constructor Details

#initialize(boundary, name, value, headers = {}) ⇒ ParamPart

Returns a new instance of ParamPart.



19
20
21
22
# File 'lib/restforce/patches/parts.rb', line 19

def initialize(boundary, name, value, headers = {})
  @part = build_part(boundary, name, value, headers)
  @io = StringIO.new(@part)
end

Instance Method Details

#build_part(boundary, name, value, headers = {}) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/restforce/patches/parts.rb', line 24

def build_part(boundary, name, value, headers = {})
  part = ''
  part << "--#{boundary}\r\n"
  part << "Content-Disposition: form-data; name=\"#{name}\"\r\n"
  part << "Content-Type: #{headers['Content-Type']}\r\n" if headers["Content-Type"]
  part << "\r\n"
  part << "#{value}\r\n"
end