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) ⇒ Body

Returns a new instance of Body



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

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

Instance Method Details

#boundaryObject



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

def boundary
  @boundary ||= MultipartBoundary.generate
end

#callObject



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

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

#multipart?Boolean

Returns:

  • (Boolean)


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

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