[Groonga-commit] ranguba/rroonga at 3762ba6 [master] Bind grn_obj_is_selector_only_proc() to Object#selector_only_procedure?

Back to archive index

Masafumi Yokoyama null+****@clear*****
Thu Jul 30 03:37:08 JST 2015


Masafumi Yokoyama	2015-07-30 03:37:08 +0900 (Thu, 30 Jul 2015)

  New Revision: 3762ba654c0e40c73b32ce43b87c4336bb3cb936
  https://github.com/ranguba/rroonga/commit/3762ba654c0e40c73b32ce43b87c4336bb3cb936

  Message:
    Bind grn_obj_is_selector_only_proc() to Object#selector_only_procedure?
    
    GitHub #106

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

  Modified: ext/groonga/rb-grn-object.c (+29 -1)
===================================================================
--- ext/groonga/rb-grn-object.c    2015-07-30 03:35:52 +0900 (be8d879)
+++ ext/groonga/rb-grn-object.c    2015-07-30 03:37:08 +0900 (a87f84e)
@@ -1,7 +1,7 @@
 /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
   Copyright (C) 2009-2014  Kouhei Sutou <kou �� clear-code.com>
-  Copyright (C) 2014  Masafumi Yokoyama <myokoym �� gmail.com>
+  Copyright (C) 2014-2015  Masafumi Yokoyama <yokoyama �� 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
@@ -1605,6 +1605,32 @@ rb_grn_object_selector_procedure_p (VALUE self)
 }
 
 /*
+ * Checks whether the object is selector only procedure or not.
+ *
+ * @overload selector_only_procedure?
+ *   @return [Boolean] `true` if the object is selector only procedure,
+ *     `false` otherwise.
+ *
+ * @since 5.0.5
+ */
+static VALUE
+rb_grn_object_selector_only_procedure_p (VALUE self)
+{
+    grn_ctx *context;
+    grn_obj *object;
+    grn_bool selector_only_procedure_p = GRN_FALSE;
+
+    rb_grn_object_deconstruct(SELF(self), &object, &context,
+                              NULL, NULL, NULL, NULL);
+
+    if (context && object) {
+        selector_only_procedure_p = grn_obj_is_selector_only_proc(context, object);
+    }
+
+    return CBOOL2RVAL(selector_only_procedure_p);
+}
+
+/*
  * Checks whether the object is scorer procedure or not.
  *
  * @overload scorer_procedure?
@@ -1671,6 +1697,8 @@ rb_grn_init_object (VALUE mGrn)
                      rb_grn_object_function_procedure_p, 0);
     rb_define_method(rb_cGrnObject, "selector_procedure?",
                      rb_grn_object_selector_procedure_p, 0);
+    rb_define_method(rb_cGrnObject, "selector_only_procedure?",
+                     rb_grn_object_selector_only_procedure_p, 0);
     rb_define_method(rb_cGrnObject, "scorer_procedure?",
                      rb_grn_object_scorer_procedure_p, 0);
 }

  Modified: test/test-procedure.rb (+15 -0)
===================================================================
--- test/test-procedure.rb    2015-07-30 03:35:52 +0900 (9374baa)
+++ test/test-procedure.rb    2015-07-30 03:37:08 +0900 (712f093)
@@ -1,4 +1,5 @@
 # Copyright (C) 2009-2014  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2015  Masafumi Yokoyama <yokoyama �� 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
@@ -70,4 +71,18 @@ class ProcedureTest < Test::Unit::TestCase
       assert_equal(Groonga::ProcedureType::SCORER, scorer.type)
     end
   end
+
+  class SelectorOnlyProcedureTest < self
+    def test_true
+      assert do
+        Groonga["sub_filter"].selector_only_procedure?
+      end
+    end
+
+    def test_false
+      assert do
+        not Groonga["between"].selector_only_procedure?
+      end
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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