summaryrefslogtreecommitdiff
path: root/storage/mroonga/vendor/groonga/lib/mrb/scripts/table_cursor.rb
blob: a36d88d556d2d73889dbbd753cc4977a17b041ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Groonga
  class TableCursor
    class << self
      def open(*arguments)
        cursor = open_raw(*arguments)
        if block_given?
          begin
            yield(cursor)
          ensure
            cursor.close
          end
        else
          cursor
        end
      end
    end

    def each
      loop do
        id = self.next
        return if id == Groonga::ID::NIL
        yield(id)
      end
    end
  end
end