qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcpie...@apache.org
Subject [03/34] qpid-proton git commit: PROTON-799: Added the object/object= methods to Ruby Data class
Date Thu, 14 May 2015 20:23:40 GMT
PROTON-799: Added the object/object= methods to Ruby Data class


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/918759a5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/918759a5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/918759a5

Branch: refs/heads/ruby-engine-apis
Commit: 918759a54c0643dde8621ff168c4e146b1d35481
Parents: 41b9b85
Author: Darryl L. Pierce <mcpierce@gmail.com>
Authored: Mon Feb 16 15:33:08 2015 -0500
Committer: Darryl L. Pierce <mcpierce@gmail.com>
Committed: Thu May 14 09:28:11 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/codec/data.rb | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/918759a5/proton-c/bindings/ruby/lib/codec/data.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/codec/data.rb b/proton-c/bindings/ruby/lib/codec/data.rb
index 69e9ed1..efefa99 100644
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ b/proton-c/bindings/ruby/lib/codec/data.rb
@@ -96,13 +96,13 @@ module Qpid::Proton::Codec
       end
 
       # destructor
-      ObjectSpace.define_finalizer(self, self.class.finalize!(@data))
+      ObjectSpace.define_finalizer(self, self.class.finalize!(@data, @free))
     end
 
     # @private
-    def self.finalize!(data)
+    def self.finalize!(data, free)
       proc {
-        Cproton.pn_data_free(data) if @free
+        Cproton.pn_data_free(data) if free
       }
     end
 
@@ -441,6 +441,27 @@ module Qpid::Proton::Codec
       null
     end
 
+    # Puts an arbitrary object type.
+    #
+    # The Data instance will determine which AMQP type is appropriate and will
+    # use that to encode the object.
+    #
+    # @param object [Object] The value.
+    #
+    def object=(object)
+      Mapping.for_class(object.class).put(self, object)
+    end
+
+    # Gets the current node, based on how it was encoded.
+    #
+    # @return [Object] The current node.
+    #
+    def object
+      type = self.type
+      return nil if type.nil?
+      type.get(data)
+    end
+
     # Checks if the current node is null.
     #
     # @return [Boolean] True if the node is null.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message