Skip to content

Commit f91905c

Browse files
committed
each, each_hash return self when called with block. allows chaining;
also update docs
1 parent f5110f0 commit f91905c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/sqlite3/resultset.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,26 @@ def next
4343
@stmt.step
4444
end
4545

46-
# Required by the Enumerable mixin. Provides an internal iterator over the
47-
# rows of the result set.
46+
# With a block given, iterates over the rows of the result set, passing each
47+
# to the block. Returns self.
48+
# With no block given, returns a new Enumerator.
4849
def each
4950
return enum_for(__method__) unless block_given?
5051
while (node = self.next)
5152
yield node
5253
end
54+
self
5355
end
5456

55-
# Provides an internal iterator over the rows of the result set where
56-
# each row is yielded as a hash.
57+
# With a block given, iterates over the rows of the result set, passing each
58+
# to the block as a hash. Returns self.
59+
# With no block given, returns a new Enumerator.
5760
def each_hash
5861
return enum_for(__method__) unless block_given?
5962
while (node = next_hash)
6063
yield node
6164
end
65+
self
6266
end
6367

6468
# Closes the statement that spawned this result set.

0 commit comments

Comments
 (0)