summaryrefslogtreecommitdiff
path: root/qpid/cpp/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/bindings')
-rw-r--r--qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb29
-rw-r--r--qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb16
2 files changed, 34 insertions, 11 deletions
diff --git a/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb b/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb
index f04dcea1db..28475f84fd 100644
--- a/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb
+++ b/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb
@@ -52,6 +52,35 @@ module Qpid
message.content
end
+ # Takes as input any type and converts anything that's a symbol
+ # into a string.
+ def self.stringify(value)
+ # set the default value
+ result = value
+
+ case value
+
+ when Symbol
+ result = value.to_s
+
+ when Hash
+ result = {}
+ value.each_pair do |key, value|
+ result[stringify(key)] = stringify(value)
+ end
+
+ when Array
+ result = []
+ value.each do |element|
+ result << stringify(element)
+ end
+
+ end
+
+ return result
+
+ end
+
end
end
diff --git a/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb b/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb
index d58b10b1e5..b9f54b981c 100644
--- a/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb
+++ b/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb
@@ -283,14 +283,14 @@ module Qpid
# Assigns a value to the named property.
#
- # *NOTE:* Both the key or the value may be a symbol, but they will
- # both be converted to a +String+ for ease of transport.
- #
# ==== Options
#
# * name - the property name
# * value - the property value
- def []=(key, value); @message_impl.setProperty(key.to_s, value.to_s); end
+ def []=(key, value)
+ @message_impl.setProperty(key.to_s,
+ Qpid::Messaging.stringify(value))
+ end
# Sets the content for the +Message+.
#
@@ -309,18 +309,12 @@ module Qpid
#
def content=(content)
content_type = nil
- @content = content
+ @content = Qpid::Messaging.stringify(content)
case @content
when Hash
content_type = "amqp/map"
- new_content = {}
- content.each_pair{|key, value| new_content[key.to_s] = value.to_s}
- @content = new_content
when Array
- new_content = []
content_type = "amqp/list"
- content.each {|element| new_content << element.to_s}
- @content = new_content
end
if content_type.nil?
@message_impl.setContent @content