[Groonga-commit] ranguba/groonga-client-model at 19fc221 [master] Add #id

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Wed Dec 7 11:55:04 JST 2016


Kouhei Sutou	2016-12-07 11:55:04 +0900 (Wed, 07 Dec 2016)

  New Revision: 19fc221246e35d74e61160ea98cf057f431a0ee0
  https://github.com/ranguba/groonga-client-model/commit/19fc221246e35d74e61160ea98cf057f431a0ee0

  Message:
    Add #id

  Added files:
    test/unit/test_record.rb
  Modified files:
    lib/groonga_client_model/record.rb

  Modified: lib/groonga_client_model/record.rb (+6 -2)
===================================================================
--- lib/groonga_client_model/record.rb    2016-12-07 11:14:27 +0900 (6b4f52d)
+++ lib/groonga_client_model/record.rb    2016-12-07 11:55:04 +0900 (1958233)
@@ -154,9 +154,13 @@ module GroongaClientModel
       self
     end
 
+    def id
+      _id
+    end
+
     def to_key
       if persisted?
-        [_id.to_s]
+        [id.to_s]
       else
         nil
       end
@@ -164,7 +168,7 @@ module GroongaClientModel
 
     def to_param
       if persisted?
-        _id.to_s
+        id.to_s
       else
         nil
       end

  Added: test/unit/test_record.rb (+34 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/test_record.rb    2016-12-07 11:55:04 +0900 (1e2ad0b)
@@ -0,0 +1,34 @@
+# Copyright (C) 2016  Kouhei Sutou <kou �� clear-code.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+class TestRecord < Test::Unit::TestCase
+  class Memo < GroongaClientModel::Record
+    class << self
+      def columns
+        GroongaClientModel::Schema::Columns.new("_id" => {})
+      end
+    end
+  end
+
+  setup do
+    @memo = Memo.new
+  end
+
+  test "#id" do
+    @memo._id = 29
+    assert_equal(29, @memo.id)
+  end
+end
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る