Class: Kybus::Client::Format::JSONFormat

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

Overview

Implements JSON format for http clients.

Direct Known Subclasses

URLEncodedFormat

Instance Method Summary collapse

Instance Method Details

#pack(data) ⇒ Object



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

def pack(data)
  {
    body: data.to_json,
    headers: { 'Content-type' => 'application/json; charset=UTF-8',
               'User-Agent' => 'Ruby Kybus Client' }
  }
end

#unformat(msg) ⇒ Object



22
23
24
# File 'lib/kybus/client/format/json_format.rb', line 22

def unformat(msg)
  JSON.parse(msg, symbolize_names: true)
end

#unpack(data) ⇒ Object



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

def unpack(data)
  unformat(data)
end