Kouhei Sutou
null+****@clear*****
Tue Sep 30 19:03:34 JST 2014
Kouhei Sutou 2014-09-30 19:03:34 +0900 (Tue, 30 Sep 2014) New Revision: c2f5fa28bd7862fea08e912c2d023a0bf44fb805 https://github.com/groonga/groonga-command/commit/c2f5fa28bd7862fea08e912c2d023a0bf44fb805 Message: Define key? and make has_key? as alias of key? Because Ruby recommend to use key?. Modified files: lib/groonga/command/base.rb test/command/test-base.rb Modified: lib/groonga/command/base.rb (+3 -2) =================================================================== --- lib/groonga/command/base.rb 2014-03-15 21:40:33 +0900 (f7043af) +++ lib/groonga/command/base.rb 2014-09-30 19:03:34 +0900 (86a95eb) @@ -56,9 +56,10 @@ module Groonga @arguments[normalize_name(name)] = value end - def has_key?(name) - @arguments.has_key?(normalize_name(name)) + def key?(name) + @arguments.key?(normalize_name(name)) end + alias_method :has_key?, :key? def ==(other) other.is_a?(self.class) and Modified: test/command/test-base.rb (+14 -0) =================================================================== --- test/command/test-base.rb 2014-03-15 21:40:33 +0900 (9d316c7) +++ test/command/test-base.rb 2014-09-30 19:03:34 +0900 (de7d022) @@ -98,6 +98,20 @@ class BaseCommandTest < Test::Unit::TestCase end end + sub_test_case("#key?") do + def setup + @select = Groonga::Command::Base.new("select", :table => "Users") + end + + def test_symbol + assert_true(@select.key?(:table)) + end + + def test_string + assert_true(@select.key?("table")) + end + end + sub_test_case("#has_key?") do def setup @select = Groonga::Command::Base.new("select", :table => "Users") -------------- next part -------------- HTML����������������������������...Download