Class: Ant::Client::Format::JSONFormat

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

Direct Known Subclasses

URLEncodedFormat

Instance Method Summary collapse

Instance Method Details

#pack(data) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/ant/client/format/json_format.rb', line 7

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

#unformat(msg) ⇒ Object



19
20
21
# File 'lib/ant/client/format/json_format.rb', line 19

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

#unpack(data) ⇒ Object



15
16
17
# File 'lib/ant/client/format/json_format.rb', line 15

def unpack(data)
  unformat(data.body)
end