Class: HTTP::FormData::Urlencoded
- Inherits:
-
Object
- Object
- HTTP::FormData::Urlencoded
- Includes:
- Readable
- Defined in:
- lib/http/form_data/urlencoded.rb
Overview
application/x-www-form-urlencoded form data.
Class Method Summary collapse
-
.encoder ⇒ #call
Returns form data encoder implementation.
-
.encoder=(implementation) ⇒ void
Sets custom form data encoder implementation.
Instance Method Summary collapse
-
#content_type ⇒ String
Returns MIME type for the Content-Type header.
-
#initialize(data, encoder: nil) ⇒ Urlencoded
constructor
Creates a new Urlencoded form data instance.
Methods included from Readable
Constructor Details
#initialize(data, encoder: nil) ⇒ Urlencoded
Creates a new Urlencoded form data instance
148 149 150 151 |
# File 'lib/http/form_data/urlencoded.rb', line 148 def initialize(data, encoder: nil) encoder ||= self.class.encoder @io = StringIO.new(encoder.call(FormData.ensure_data(data))) end |
Class Method Details
.encoder ⇒ #call
Returns form data encoder implementation
65 66 67 |
# File 'lib/http/form_data/urlencoded.rb', line 65 def encoder @encoder || DefaultEncoder end |
.encoder=(implementation) ⇒ void
This method returns an undefined value.
Sets custom form data encoder implementation
51 52 53 54 55 |
# File 'lib/http/form_data/urlencoded.rb', line 51 def encoder=(implementation) raise ArgumentError unless implementation.respond_to? :call @encoder = implementation end |
Instance Method Details
#content_type ⇒ String
Returns MIME type for the Content-Type header
161 162 163 |
# File 'lib/http/form_data/urlencoded.rb', line 161 def content_type "application/x-www-form-urlencoded" end |