You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2015/06/03 22:30:58 UTC
[21/34] qpid-proton git commit: PROTON-799: Added the Disposition
class to the Ruby engine APIs.
PROTON-799: Added the Disposition class to the Ruby engine APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/6057afec
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6057afec
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6057afec
Branch: refs/heads/master
Commit: 6057afec7fc9ef926818b4697f21ee14295696f7
Parents: 6a4e6a6
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Tue Jan 20 14:31:59 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Wed Jun 3 16:29:23 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/disposition.rb | 158 ++++++++++++++++++++
proton-c/bindings/ruby/lib/core/exceptions.rb | 10 ++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
3 files changed, 169 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6057afec/proton-c/bindings/ruby/lib/core/disposition.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/disposition.rb b/proton-c/bindings/ruby/lib/core/disposition.rb
new file mode 100644
index 0000000..20dafd7
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/core/disposition.rb
@@ -0,0 +1,158 @@
+#--
+# 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.
+#++
+
+module Qpid::Proton
+
+ # Disposition records the current state and/or final outcome of a transfer.
+ #
+ # Every delivery contains both a local and a remote disposition. The local
+ # disposition holds the local state of the delivery, and the remote
+ # disposition holds the *last known* remote state of the delivery.
+ #
+ class Disposition
+
+ include Util::Constants
+
+ # Indicates the delivery was received.
+ self.add_constant(:RECEIVED, Cproton::PN_RECEIVED)
+ # Indicates the delivery was accepted.
+ self.add_constant(:ACCEPTED, Cproton::PN_ACCEPTED)
+ # Indicates the delivery was rejected.
+ self.add_constant(:REJECTED, Cproton::PN_REJECTED)
+ # Indicates the delivery was released.
+ self.add_constant(:RELEASED, Cproton::PN_RELEASED)
+ # Indicates the delivery was modified.
+ self.add_constant(:MODIFIED, Cproton::PN_MODIFIED)
+
+ # @private
+ include Util::Engine
+
+ attr_reader :impl
+
+ # @private
+ def initialize(impl, local)
+ @impl = impl
+ @local = local
+ @data = nil
+ @condition = nil
+ @annotations = nil
+ end
+
+ # @private
+ include Util::SwigHelper
+
+ # @private
+ PROTON_METHOD_PREFIX = "pn_disposition"
+
+ # @!attribute section_number
+ #
+ # @return [Fixnum] The section number of the disposition.
+ #
+ proton_accessor :section_number
+
+ # @!attribute section_offset
+ #
+ # @return [Fixnum] The section offset of the disposition.
+ #
+ proton_accessor :section_offset
+
+ # @!attribute failed?
+ #
+ # @return [Boolean] The failed flag.
+ #
+ proton_accessor :failed, :is_or_get => :is
+
+ # @!attribute undeliverable?
+ #
+ # @return [Boolean] The undeliverable flag.
+ #
+ proton_accessor :undeliverable, :is_or_get => :is
+
+ # Sets the data for the disposition.
+ #
+ # @param data [Codec::Data] The data.
+ #
+ # @raise [AttributeError] If the disposition is remote.
+ #
+ def data=(data)
+ raise AttributeError.new("data attribute is read-only") unless @local
+ @data = data
+ end
+
+ # Returns the data for the disposition.
+ #
+ # @return [Codec::Data] The data.
+ #
+ def data
+ if @local
+ @data
+ else
+ data_to_object(Cproton.pn_disposition_data(@impl))
+ end
+ end
+
+ # Sets the annotations for the disposition.
+ #
+ # @param annotations [Codec::Data] The annotations.
+ #
+ # @raise [AttributeError] If the disposition is remote.
+ #
+ def annotations=(annotations)
+ raise AttributeError.new("annotations attribute is read-only") unless @local
+ @annotations = annotations
+ end
+
+ # Returns the annotations for the disposition.
+ #
+ # @return [Codec::Data] The annotations.
+ #
+ def annotations
+ if @local
+ @annotations
+ else
+ data_to_object(Cproton.pn_disposition_annotations(@impl))
+ end
+ end
+
+ # Sets the condition for the disposition.
+ #
+ # @param condition [Codec::Data] The condition.
+ #
+ # @raise [AttributeError] If the disposition is remote.
+ #
+ def condition=(condition)
+ raise AttributeError.new("condition attribute is read-only") unless @local
+ @condition = condition
+ end
+
+ # Returns the condition of the disposition.
+ #
+ # @return [Codec::Data] The condition of the disposition.
+ #
+ def condition
+ if @local
+ @condition
+ else
+ condition_to_object(Cproton.pn_disposition_condition(@impl))
+ end
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6057afec/proton-c/bindings/ruby/lib/core/exceptions.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/exceptions.rb b/proton-c/bindings/ruby/lib/core/exceptions.rb
index 4e0bfc1..8dead61 100644
--- a/proton-c/bindings/ruby/lib/core/exceptions.rb
+++ b/proton-c/bindings/ruby/lib/core/exceptions.rb
@@ -85,6 +85,16 @@ module Qpid
class SessionError < ProtonError
end
+ # Raised when an attempt is made to change an attribute that is read-only.
+ #
+ class AttributeError < ProtonError
+ end
+
+ # Raised by link components.
+ #
+ class LinkError < ProtonError
+ end
+
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6057afec/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index dd162f3..84c39fc 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -57,6 +57,7 @@ require "core/message"
require "core/endpoint"
require "core/session"
require "core/terminus"
+require "core/disposition"
# Messenger API classes
require "messenger/filters"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org