module Qpid::Messaging

Public Class Methods

decode(message, content_type = nil) click to toggle source

Decodes and returns the message’s content.

# File qpid/ruby/lib/qpid_messaging/encoding.rb, line 42
def self.decode(message, content_type = nil)
  content_type = message.content_type unless content_type

  case content_type
    when "amqp/map"
      Cqpid.decodeMap message.message_impl
    when "amqp/list"
      Cqpid.decodeList message.message_impl
  end

  message.content
end
encode(content, message, encoding = nil) click to toggle source

Encodes the supplied content into the given message.

# File qpid/ruby/lib/qpid_messaging/encoding.rb, line 25
def self.encode content, message, encoding = nil
  prepared = content
  case content
  when Hash
    prepared = {}
    content.each_pair do |key,value|
      prepared[key.to_s] = value.to_s
    end
    Cqpid::encode prepared, message.message_impl
  when Array
    prepared = []
    content.each {|value| prepared << value.to_s}
    Cqpid::encode prepared, message.message_impl
  end
end