Class: PayPalHttp::FormEncoded
- Inherits:
-
Object
- Object
- PayPalHttp::FormEncoded
- Defined in:
- lib/paypalhttp/serializers/form_encoded.rb
Instance Method Summary collapse
- #content_type ⇒ Object
- #decode(body) ⇒ Object
- #encode(request) ⇒ Object
-
#initialize ⇒ FormEncoded
constructor
A new instance of FormEncoded.
Constructor Details
#initialize ⇒ FormEncoded
Returns a new instance of FormEncoded.
5 6 7 |
# File 'lib/paypalhttp/serializers/form_encoded.rb', line 5 def initialize @parser = URI::Parser.new() end |
Instance Method Details
#content_type ⇒ Object
22 23 24 |
# File 'lib/paypalhttp/serializers/form_encoded.rb', line 22 def content_type /^application\/x-www-form-urlencoded/ end |
#decode(body) ⇒ Object
18 19 20 |
# File 'lib/paypalhttp/serializers/form_encoded.rb', line 18 def decode(body) raise UnsupportedEncodingError.new("FormEncoded does not support deserialization") end |
#encode(request) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/paypalhttp/serializers/form_encoded.rb', line 9 def encode(request) encoded_params = [] request.body.each do |k, v| encoded_params.push("#{@parser.escape(k.to_s)}=#{@parser.escape(v.to_s)}") end encoded_params.join("&") end |