PROTON-1789: [ruby] Remove incorrect type-adjustments for maps Removed incorrect code to force the key type of application-properties and annotation maps to SYMBOL. For now the user is required to use the correct types. We may add correct validation or conversion code in future.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/06e931f6 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/06e931f6 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/06e931f6 Branch: refs/heads/go1 Commit: 06e931f6ee4d0631e68131b21e6f84d83ba8b913 Parents: bbe9195 Author: Alan Conway <[email protected]> Authored: Wed Mar 28 12:31:23 2018 -0400 Committer: Alan Conway <[email protected]> Committed: Wed Mar 28 12:31:23 2018 -0400 ---------------------------------------------------------------------- proton-c/bindings/ruby/lib/core/connection.rb | 9 +++------ proton-c/bindings/ruby/lib/core/message.rb | 12 +++--------- proton-c/bindings/ruby/lib/types/hash.rb | 17 ----------------- proton-c/bindings/ruby/tests/test_container.rb | 6 +++--- 4 files changed, 9 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/lib/core/connection.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/core/connection.rb b/proton-c/bindings/ruby/lib/core/connection.rb index dc2590f..e54ce16 100644 --- a/proton-c/bindings/ruby/lib/core/connection.rb +++ b/proton-c/bindings/ruby/lib/core/connection.rb @@ -134,12 +134,9 @@ module Qpid::Proton Cproton.pn_connection_set_password(@impl, opts[:password]) if opts[:password] Cproton.pn_connection_set_hostname(@impl, opts[:virtual_host]) if opts[:virtual_host] @link_prefix = opts[:link_prefix] || cid - Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl), - Types.symbol_array(opts[:offered_capabilities])) - Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl), - Types.symbol_array(opts[:desired_capabilities])) - Codec::Data.from_object(Cproton.pn_connection_properties(@impl), - Types.symbol_keys(opts[:properties])) + Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl), opts[:offered_capabilities]) + Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl), opts[:desired_capabilities]) + Codec::Data.from_object(Cproton.pn_connection_properties(@impl), opts[:properties]) end # Idle-timeout advertised by the remote peer, in seconds. http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/lib/core/message.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/core/message.rb b/proton-c/bindings/ruby/lib/core/message.rb index 9afaa0a..9f83cfd 100644 --- a/proton-c/bindings/ruby/lib/core/message.rb +++ b/proton-c/bindings/ruby/lib/core/message.rb @@ -70,18 +70,12 @@ module Qpid::Proton end end + # @private nill # @private def pre_encode # encode elements from the message - Codec::Data.from_object(Cproton::pn_message_properties(@impl), - [email protected]? && Types.symbol_keys!(@properties)) - Codec::Data.from_object(Cproton::pn_message_instructions(@impl), - [email protected]? && Types.symbol_keys!(@instructions)) - if @annotations # Make sure keys are symbols - @annotations.keys.each do |k| - @annotations[k.to_sym] = @annotations.delete(k) unless k.is_a? Symbol - end - end + Codec::Data.from_object(Cproton::pn_message_properties(@impl), [email protected]? && @properties) + Codec::Data.from_object(Cproton::pn_message_instructions(@impl), [email protected]? && @instructions) Codec::Data.from_object(Cproton::pn_message_annotations(@impl), [email protected]? && @annotations) Codec::Data.from_object(Cproton::pn_message_body(@impl), @body) end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/lib/types/hash.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb index 70d54bd..a4bad8f 100644 --- a/proton-c/bindings/ruby/lib/types/hash.rb +++ b/proton-c/bindings/ruby/lib/types/hash.rb @@ -37,20 +37,3 @@ class Hash # :nodoc: end end -module Qpid::Proton::Types - # @private - def self.symbol_keys(h) - h && h.reduce({}) { |x, (k, v)| x[k.to_sym] = v; x } - end - - # @private - def self.symbol_keys!(h) - h.keys.each { |k| h[k.to_sym] = h.delete(k) unless k.is_a? Symbol } if h - h - end - - # @private - def self.symbol_array(a) - a && UniformArray.new(SYMBOL, a.collect { |v| v.to_sym }) - end -end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/06e931f6/proton-c/bindings/ruby/tests/test_container.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb index adce409..1026d46 100644 --- a/proton-c/bindings/ruby/tests/test_container.rb +++ b/proton-c/bindings/ruby/tests/test_container.rb @@ -183,9 +183,9 @@ class ContainerTest < MiniTest::Test }) client = cont.connect(cont.url, {:virtual_host => "client.to.server", - :properties => { :foo => :bar, "str" => "str" }, + :properties => { "foo" => :bar, "str" => "str" }, :offered_capabilities => [:c1 ], - :desired_capabilities => ["c2" ], + :desired_capabilities => [:c2 ], :idle_timeout => 42, :max_sessions =>100, :max_frame_size => 4096, @@ -195,7 +195,7 @@ class ContainerTest < MiniTest::Test c = server_handler.connection assert_equal "client.to.server", c.virtual_host - assert_equal({ :foo => :bar, :str => "str" }, c.properties) + assert_equal({ "foo" => :bar, "str" => "str" }, c.properties) assert_equal([:c1], c.offered_capabilities) assert_equal([:c2], c.desired_capabilities) assert_equal 21, c.idle_timeout # Proton divides by 2 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
