Class: HTTPX::Transcoder::Form::Encoder

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/httpx/transcoder/form.rb

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ Encoder

Returns a new instance of Encoder.



23
24
25
26
27
28
29
30
31
# File 'lib/httpx/transcoder/form.rb', line 23

def initialize(form)
  @raw = form.each_with_object("".b) do |(key, val), buf|
    HTTPX::Transcoder.normalize_keys(key, val) do |k, v|
      buf << "&" unless buf.empty?
      buf << URI.encode_www_form_component(k)
      buf << "=#{URI.encode_www_form_component(v.to_s)}" unless v.nil?
    end
  end
end

Instance Method Details

#content_typeObject



33
34
35
# File 'lib/httpx/transcoder/form.rb', line 33

def content_type
  "application/x-www-form-urlencoded"
end