[Groonga-commit] ranguba/groonga-client-model at 37e3fc3 [master] Support saving Array

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Dec 7 11:14:27 JST 2016


Kouhei Sutou	2016-12-07 11:14:27 +0900 (Wed, 07 Dec 2016)

  New Revision: 37e3fc343e33908d042c7b10685ceead3a781ead
  https://github.com/ranguba/groonga-client-model/commit/37e3fc343e33908d042c7b10685ceead3a781ead

  Message:
    Support saving Array

  Modified files:
    lib/groonga_client_model/load_value_generator.rb
    test/unit/test_load_value_generator.rb

  Modified: lib/groonga_client_model/load_value_generator.rb (+5 -1)
===================================================================
--- lib/groonga_client_model/load_value_generator.rb    2016-12-07 10:59:59 +0900 (65ab6d8)
+++ lib/groonga_client_model/load_value_generator.rb    2016-12-07 11:14:27 +0900 (4ccdc5c)
@@ -39,8 +39,12 @@ module GroongaClientModel
         value.strftime("%Y-%m-%d %H:%M:%S.%6N")
       when Record
         format_value(value._key)
+      when Array
+        value.collect do |sub_value|
+          format_value(sub_value)
+        end
       else
-        value = value
+        value
       end
     end
   end

  Modified: test/unit/test_load_value_generator.rb (+11 -0)
===================================================================
--- test/unit/test_load_value_generator.rb    2016-12-07 10:59:59 +0900 (d213f94)
+++ test/unit/test_load_value_generator.rb    2016-12-07 11:14:27 +0900 (b406803)
@@ -19,6 +19,7 @@ class TestLoadValueGenerator < Test::Unit::TestCase
     class << self
       def columns
         GroongaClientModel::Schema::Columns.new("tag" => {},
+                                                "tags" => {},
                                                 "created_at" => {})
       end
     end
@@ -55,4 +56,14 @@ class TestLoadValueGenerator < Test::Unit::TestCase
     assert_equal({"tag" => "important"},
                  @generator.generate)
   end
+
+  test "Array" do
+    tags = [
+      Tag.new(_key: "important"),
+      Tag.new(_key: "groonga"),
+    ]
+    @memo.tags = tags
+    assert_equal({"tags" => ["important", "groonga"]},
+                 @generator.generate)
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index