Class: AmqpUtils::MessageFormatter::JSON

Inherits:
Base
  • Object
show all
Defined in:
lib/amqp_utils/message_formatter.rb

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#generate(io, header, message) ⇒ Object



44
45
46
47
# File 'lib/amqp_utils/message_formatter.rb', line 44

def generate(io, header, message)
  json_obj = {'header' => header.properties, 'message' => message}
  io.puts ::JSON.generate(json_obj)
end

#load(io) ⇒ Object



49
50
51
52
# File 'lib/amqp_utils/message_formatter.rb', line 49

def load(io)
  next_line = io.gets
  ::JSON.parse(next_line) if next_line
end