summaryrefslogtreecommitdiff
path: root/cpp/bindings/qpid/ruby/lib
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2011-07-15 16:59:26 +0000
committerTed Ross <tross@apache.org>2011-07-15 16:59:26 +0000
commit36b0ea9d30aa02c9bdd63d82ae3a0f89d9f9f77f (patch)
tree07de7bf24de9d77797b02d06749e0d0696a8cffd /cpp/bindings/qpid/ruby/lib
parentfeeba1d6a71494c19d71f903d7f9d735881343ec (diff)
downloadqpid-python-36b0ea9d30aa02c9bdd63d82ae3a0f89d9f9f77f.tar.gz
QPID-3306 - Provides a more Ruby-like set of APIs on top of the bindings created by swig.
Applied patch from Darryl Pierce Created the Message class and its unit tests. The class is packaged as: Qpid::Messaging::Message A Message can return its content and be used to send a message over an instance of Sender. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1147241 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/ruby/lib')
-rw-r--r--cpp/bindings/qpid/ruby/lib/qpid.rb1
-rw-r--r--cpp/bindings/qpid/ruby/lib/qpid/message.rb129
2 files changed, 130 insertions, 0 deletions
diff --git a/cpp/bindings/qpid/ruby/lib/qpid.rb b/cpp/bindings/qpid/ruby/lib/qpid.rb
index f9d5822bbd..b5ac578b7c 100644
--- a/cpp/bindings/qpid/ruby/lib/qpid.rb
+++ b/cpp/bindings/qpid/ruby/lib/qpid.rb
@@ -21,4 +21,5 @@ require 'qpid/errors'
require 'qpid/duration'
require 'qpid/address'
require 'qpid/encoding'
+require 'qpid/message'
diff --git a/cpp/bindings/qpid/ruby/lib/qpid/message.rb b/cpp/bindings/qpid/ruby/lib/qpid/message.rb
new file mode 100644
index 0000000000..652b9fe564
--- /dev/null
+++ b/cpp/bindings/qpid/ruby/lib/qpid/message.rb
@@ -0,0 +1,129 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require 'cqpid'
+
+module Qpid
+
+ module Messaging
+
+ # Message represents a message.
+ class Message
+
+ def initialize(args = {}, message_impl = nil)
+ @message_impl = message_impl
+ @message_impl = Cqpid::Message.new if @message_impl.nil?
+ @message_impl.setContent args[:content].to_s if args[:content]
+ end
+
+ def message_impl # :nodoc:
+ @message_impl
+ end
+
+ # Assigns the reply to address.
+ # The address must be an instance of Address.
+ def reply_to=(address); @message_impl.setReplyTo address.address_impl; end
+
+ # Returns the reply to address for the message as an instance of +Address+.
+ def reply_to
+ address_impl = @message_impl.getReplyTo
+ # only return an address if a reply to was specified
+ Qpid::Messaging::Address.new(nil, nil, nil, nil, address_impl) if address_impl
+ end
+
+ # Sets the subject.
+ def subject=(subject); @message_impl.setSubject subject; end
+
+ # Returns the subject.
+ def subject; @message_impl.getSubject; end
+
+ # Sets the content type.
+ def content_type=(content_type); @message_impl.setContentType content_type; end
+
+ # Returns the content type.
+ def content_type; @message_impl.getContentType; end
+
+ # Sets the message id.
+ def message_id=(message_id); @message_impl.setMessageId message_id.to_s; end
+
+ # Returns the message id.
+ def message_id; @message_impl.getMessageId; end
+
+ # Sets the user id.
+ def user_id=(user_id); @message_impl.setUserId user_id; end
+
+ # Returns the user id.
+ def user_id; @message_impl.getUserId; end
+
+ # Sets the correlation id.
+ def correlation_id=(correlation_id); @message_impl.setCorrelationId correlation_id; end
+
+ # Returns the correlation id.
+ def correlation_id; @message_impl.getCorrelationId; end
+
+ # Sets the priority.
+ def priority=(priority); @message_impl.setPriority priority; end
+
+ # Returns the priority.
+ def priority; @message_impl.getPriority; end
+
+ # Sets the time-to-live in milliseconds.
+ def ttl=(duration); @message_impl.setTtl duration; end
+
+ # Returns the time-to-live in milliseconds.
+ def ttl; @message_impl.getTtl; end
+
+ # Sets the durability.
+ def durable=(durable); @message_impl.setDurable durable; end
+
+ # Returns the durability.
+ def durable; @message_impl.getDurable; end
+
+ # Allows marking the message as redelivered.
+ def redelivered=(redelivered); @message_impl.setRedelivered redelivered; end
+
+ # Returns if the message was redelivered.
+ def redelivered; @message_impl.getRedelivered; end
+
+ # Returns all named properties.
+ # *NOTE:* It is recommended to use the +foo[key]+ method for
+ # retrieving properties.
+ def properties; @message_impl.getProperties; end
+
+ # Returns the value for the named property.
+ def [](key); self.properties[key.to_s]; end
+
+ # Assigns a value to the named property.
+ 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
+
+ # Returns the content.
+ def content; @message_impl.getContent; end
+
+ # Returns the content's size.
+ def content_size; @message_impl.getContentSize; end
+
+ end
+
+ end
+
+end
+