[Groonga-commit] groonga/groonga at 9121275 [master] mrb: add Database#each_name

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jul 22 13:12:11 JST 2015


Kouhei Sutou	2015-07-22 13:12:11 +0900 (Wed, 22 Jul 2015)

  New Revision: 9121275361901c9e1f384a94020a797336c52c60
  https://github.com/groonga/groonga/commit/9121275361901c9e1f384a94020a797336c52c60

  Message:
    mrb: add Database#each_name

  Modified files:
    lib/mrb/scripts/database.rb

  Modified: lib/mrb/scripts/database.rb (+12 -5)
===================================================================
--- lib/mrb/scripts/database.rb    2015-07-21 21:52:13 +0900 (653e9ed)
+++ lib/mrb/scripts/database.rb    2015-07-22 13:12:11 +0900 (a5a89ed)
@@ -13,8 +13,7 @@ module Groonga
       end
     end
 
-    def each_table(options={})
-      context = Context.instance
+    def each_name(options={})
       min = options[:prefix]
       flags = 0
       if options[:order] == :descending
@@ -30,11 +29,19 @@ module Groonga
       flags |= TableCursorFlags::PREFIX if min
       TableCursor.open(self, :min => min, :flags => flags) do |cursor|
         cursor.each do |id|
-          next if cursor.key.include?(".")
-          object = context[id]
-          yield(object) if object.is_a?(Table)
+          name = cursor.key
+          yield(name)
         end
       end
     end
+
+    def each_table(options={})
+      context = Context.instance
+      each_name(options) do |name|
+        next if name.include?(".")
+        object = context[name]
+        yield(object) if object.is_a?(Table)
+      end
+    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Télécharger 



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