Class: Kybus::Client::Format::URLEncodedFormat

Inherits:
JSONFormat
  • Object
show all
Defined in:
lib/kybus/client/format/url_encoded.rb

Overview

Allows to send data url encoded as a regular http client.

Instance Method Summary collapse

Methods inherited from JSONFormat

#unformat, #unpack

Instance Method Details

#encode(data) ⇒ Object



18
19
20
# File 'lib/kybus/client/format/url_encoded.rb', line 18

def encode(data)
  data.map { |k, v| "#{k}=#{v}" }.join('&')
end

#pack(data) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/kybus/client/format/url_encoded.rb', line 10

def pack(data)
  {
    body: encode(data),
    headers: { 'Content-type' =>
               'application/x-www-form-urlencoded; charset=UTF-8' }
  }
end