Class: HTTParty::Request::Body

Inherits:
Object
  • Object
show all
Defined in:
lib/httparty/request/body.rb

Instance Method Summary collapse

Constructor Details

#initialize(params, query_string_normalizer: nil, force_multipart: false) ⇒ Body

Returns a new instance of Body.



11
12
13
14
15
# File 'lib/httparty/request/body.rb', line 11

def initialize(params, query_string_normalizer: nil, force_multipart: false)
  @params = params
  @query_string_normalizer = query_string_normalizer
  @force_multipart = force_multipart
end

Instance Method Details

#boundaryObject



25
26
27
# File 'lib/httparty/request/body.rb', line 25

def boundary
  @boundary ||= MultipartBoundary.generate
end

#callObject



17
18
19
20
21
22
23
# File 'lib/httparty/request/body.rb', line 17

def call
  if params.respond_to?(:to_hash)
    multipart? ? generate_multipart : normalize_query(params)
  else
    params
  end
end

#multipart?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/httparty/request/body.rb', line 29

def multipart?
  params.respond_to?(:to_hash) && (force_multipart || has_file?(params))
end