qpid_messaging 0.18.4 → 0.18.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,35 +23,52 @@ module Qpid
23
23
 
24
24
  # Encodes the supplied content into the given message.
25
25
  def self.encode content, message, encoding = nil
26
- prepared = content
27
- case content
28
- when Hash
29
- prepared = {}
30
- content.each_pair do |key,value|
31
- prepared[key.to_s] = value.to_s
32
- end
33
- Cqpid::encode prepared, message.message_impl
34
- when Array
35
- prepared = []
36
- content.each {|value| prepared << value.to_s}
37
- Cqpid::encode prepared, message.message_impl
38
- end
26
+ Cqpid::encode content, message.message_impl, encoding
39
27
  end
40
28
 
41
29
  # Decodes and returns the message's content.
42
30
  def self.decode(message, content_type = nil)
43
- content_type = message.content_type unless content_type
31
+ content_type = message.content_type if content_type.nil?
44
32
 
45
33
  case content_type
46
34
  when "amqp/map"
47
- Cqpid.decodeMap message.message_impl
35
+ return Cqpid.decodeMap message.message_impl
48
36
  when "amqp/list"
49
- Cqpid.decodeList message.message_impl
37
+ return Cqpid.decodeList message.message_impl
50
38
  end
51
39
 
52
40
  message.content
53
41
  end
54
42
 
43
+ # Takes as input any type and converts anything that's a symbol
44
+ # into a string.
45
+ def self.stringify(value)
46
+ # set the default value
47
+ result = value
48
+
49
+ case value
50
+
51
+ when Symbol
52
+ result = value.to_s
53
+
54
+ when Hash
55
+ result = {}
56
+ value.each_pair do |key, value|
57
+ result[stringify(key)] = stringify(value)
58
+ end
59
+
60
+ when Array
61
+ result = []
62
+ value.each do |element|
63
+ result << stringify(element)
64
+ end
65
+
66
+ end
67
+
68
+ return result
69
+
70
+ end
71
+
55
72
  end
56
73
 
57
74
  end
@@ -283,14 +283,14 @@ module Qpid
283
283
 
284
284
  # Assigns a value to the named property.
285
285
  #
286
- # *NOTE:* Both the key or the value may be a symbol, but they will
287
- # both be converted to a +String+ for ease of transport.
288
- #
289
286
  # ==== Options
290
287
  #
291
288
  # * name - the property name
292
289
  # * value - the property value
293
- def []=(key, value); @message_impl.setProperty(key.to_s, value.to_s); end
290
+ def []=(key, value)
291
+ @message_impl.setProperty(key.to_s,
292
+ Qpid::Messaging.stringify(value))
293
+ end
294
294
 
295
295
  # Sets the content for the +Message+.
296
296
  #
@@ -309,18 +309,12 @@ module Qpid
309
309
  #
310
310
  def content=(content)
311
311
  content_type = nil
312
- @content = content
312
+ @content = Qpid::Messaging.stringify(content)
313
313
  case @content
314
314
  when Hash
315
315
  content_type = "amqp/map"
316
- new_content = {}
317
- content.each_pair{|key, value| new_content[key.to_s] = value.to_s}
318
- @content = new_content
319
316
  when Array
320
- new_content = []
321
317
  content_type = "amqp/list"
322
- content.each {|element| new_content << element.to_s}
323
- @content = new_content
324
318
  end
325
319
  if content_type.nil?
326
320
  @message_impl.setContent @content
@@ -23,7 +23,7 @@ module Qpid #:nodoc:
23
23
 
24
24
  NUMBERS = [MAJOR = 0,
25
25
  MINOR = 18,
26
- BUILD = 4]
26
+ BUILD = 5]
27
27
  end
28
28
 
29
29
  VERSION = Version::NUMBERS.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qpid_messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.4
4
+ version: 0.18.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: