Class: HTTPX::Transcoder::Form::Encoder
- Inherits:
-
Object
- Object
- HTTPX::Transcoder::Form::Encoder
- Extended by:
- Forwardable
- Defined in:
- lib/httpx/transcoder/form.rb
Instance Method Summary collapse
- #content_type ⇒ Object
-
#initialize(form) ⇒ Encoder
constructor
A new instance of Encoder.
Constructor Details
#initialize(form) ⇒ Encoder
Returns a new instance of Encoder.
25 26 27 28 29 30 31 32 33 |
# File 'lib/httpx/transcoder/form.rb', line 25 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_type ⇒ Object
35 36 37 |
# File 'lib/httpx/transcoder/form.rb', line 35 def content_type "application/x-www-form-urlencoded" end |