diff options
| author | Ted Ross <tross@apache.org> | 2011-09-12 21:04:02 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2011-09-12 21:04:02 +0000 |
| commit | c6fa51f7ae0ffa5dfba9143651757eded69df9d1 (patch) | |
| tree | 912ee45d11c112678c90e160c3fd36a94c07bce1 /cpp/bindings/qpid/ruby/lib | |
| parent | c6198c637cf03896563157802dccc4d62012acb9 (diff) | |
| download | qpid-python-c6fa51f7ae0ffa5dfba9143651757eded69df9d1.tar.gz | |
QPID-3480 - Directly encodes and decodes message content in Ruby
Committed patch from Darryl Pierce.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1169924 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/ruby/lib')
| -rw-r--r-- | cpp/bindings/qpid/ruby/lib/qpid/message.rb | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/cpp/bindings/qpid/ruby/lib/qpid/message.rb b/cpp/bindings/qpid/ruby/lib/qpid/message.rb index 652b9fe564..9b1b68c7c3 100644 --- a/cpp/bindings/qpid/ruby/lib/qpid/message.rb +++ b/cpp/bindings/qpid/ruby/lib/qpid/message.rb @@ -30,6 +30,7 @@ module Qpid @message_impl = message_impl @message_impl = Cqpid::Message.new if @message_impl.nil? @message_impl.setContent args[:content].to_s if args[:content] + @content = nil end def message_impl # :nodoc: @@ -113,10 +114,37 @@ module Qpid def []=(key, value); @message_impl.setProperty(key.to_s, value.to_s); end # Sets the content. - def content=(content); @message_impl.setContent content.to_s; end + def content=(content) + content_type = nil + @content = content + case @content + when Hash + content_type = "amqp/map" + when Array + content_type = "amqp/list" + end + if content_type.nil? + @message_impl.setContent @content + else + Qpid::Messaging.encode @content, self, content_type + end + end # Returns the content. - def content; @message_impl.getContent; end + def content + if @content.nil? + @content = @message_impl.getContent + + # decode the content is necessary if it + # has an encoded content type + if ["amqp/list", "amqp/map"].include? @message_impl.getContentType + @content = Qpid::Messaging.decode(self, + @message_impl.getContentType) + end + + end + @content + end # Returns the content's size. def content_size; @message_impl.getContentSize; end |
