[Groonga-commit] ranguba/rroonga at 141e461 [master] Add Groonga::Object#dirty?

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jul 15 19:40:07 JST 2016


Kouhei Sutou	2016-07-15 19:40:07 +0900 (Fri, 15 Jul 2016)

  New Revision: 141e461f1263fa956bc4b39b706232605a1c95dd
  https://github.com/ranguba/rroonga/commit/141e461f1263fa956bc4b39b706232605a1c95dd

  Message:
    Add Groonga::Object#dirty?

  Modified files:
    ext/groonga/rb-grn-object.c
    test/test-database.rb

  Modified: ext/groonga/rb-grn-object.c (+22 -0)
===================================================================
--- ext/groonga/rb-grn-object.c    2016-07-15 19:33:37 +0900 (fb5045e)
+++ ext/groonga/rb-grn-object.c    2016-07-15 19:40:07 +0900 (ac28c07)
@@ -1902,6 +1902,26 @@ rb_grn_object_get_last_modified (VALUE self)
     return rb_funcall(rb_cTime, rb_intern("at"), 1, UINT2NUM(last_modified));
 }
 
+
+/*
+ * @overload dirty?
+ *   @return [Boolean] `true` if the object isn't flushed after the last change.
+ *
+ * @since 6.0.5
+ */
+static VALUE
+rb_grn_object_dirty_p (VALUE self)
+{
+    grn_ctx *context;
+    grn_obj *object;
+    grn_bool is_dirty;
+
+    rb_grn_object_deconstruct(SELF(self), &object, &context,
+                              NULL, NULL, NULL, NULL);
+    is_dirty = grn_obj_is_dirty(context, object);
+    return CBOOL2RVAL(is_dirty);
+}
+
 void
 rb_grn_init_object (VALUE mGrn)
 {
@@ -1962,4 +1982,6 @@ rb_grn_init_object (VALUE mGrn)
     rb_define_method(rb_cGrnObject, "touch", rb_grn_object_touch, -1);
     rb_define_method(rb_cGrnObject, "last_modified",
                      rb_grn_object_get_last_modified, 0);
+    rb_define_method(rb_cGrnObject, "dirty?",
+                     rb_grn_object_dirty_p, 0);
 }

  Modified: test/test-database.rb (+11 -0)
===================================================================
--- test/test-database.rb    2016-07-15 19:33:37 +0900 (d3c92dd)
+++ test/test-database.rb    2016-07-15 19:40:07 +0900 (870e669)
@@ -375,5 +375,16 @@ class DatabaseTest < Test::Unit::TestCase
       @database.touch
       assert_equal(Time.now.sec, @database.last_modified.sec)
     end
+
+    def test_dirty?
+      omit("TODO: Enable this after Groonga 6.0.6 is released.")
+      assert do
+        not****@datab*****?
+      end
+      @database.touch
+      assert do
+        @database.dirty?
+      end
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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