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


6
7
8
9
10
# File 'lib/httparty/request/body.rb', line 6

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


20
21
22
# File 'lib/httparty/request/body.rb', line 20

def boundary
  @boundary ||= MultipartBoundary.generate
end

#callObject


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

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

#multipart?Boolean


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

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