diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-13 12:01:41 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-13 12:01:41 -0700 |
commit | f0c2c6469f142e826ac2c60673bba2d18d7df6e6 (patch) | |
tree | b04bb2641572b322ae9a2e7c4052f2af2ffd5926 | |
parent | 3c3a344aecba871ab9335dee7eee077dea1bce20 (diff) | |
download | rails-f0c2c6469f142e826ac2c60673bba2d18d7df6e6.tar.gz rails-f0c2c6469f142e826ac2c60673bba2d18d7df6e6.tar.bz2 rails-f0c2c6469f142e826ac2c60673bba2d18d7df6e6.zip |
add length to ActiveRecord::Result
-rw-r--r-- | activerecord/lib/active_record/result.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/result_test.rb | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 8405fdaeb9..3a3e65ef32 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -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 } diff --git a/activerecord/test/cases/result_test.rb b/activerecord/test/cases/result_test.rb index d6decafad9..dec01dfa76 100644 --- a/activerecord/test/cases/result_test.rb +++ b/activerecord/test/cases/result_test.rb @@ -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'}, |