1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

add length to ActiveRecord::Result

This commit is contained in:
Aaron Patterson 2014-10-13 12:01:41 -07:00
parent 3c3a344aec
commit f0c2c6469f
2 changed files with 8 additions and 0 deletions

View file

@ -42,6 +42,10 @@ module ActiveRecord
@column_types = column_types
end
def length
@rows.length
end
def each
if block_given?
hash_rows.each { |row| yield row }

View file

@ -10,6 +10,10 @@ module ActiveRecord
])
end
test "length" do
assert_equal 3, result.length
end
test "to_hash returns row_hashes" do
assert_equal [
{'col_1' => 'row 1 col 1', 'col_2' => 'row 1 col 2'},