diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-26 15:16:12 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-31 10:58:16 -0800 |
commit | 40ce68204808f9905413fe15843a7cc0f1c56988 (patch) | |
tree | e2e8f27e076006f2c57bd5baf5ddcb61a38b9254 /activerecord/lib/active_record/result.rb | |
parent | 77c6706dad7a53bf57d5c6e3980e94ea40b603eb (diff) | |
download | rails-40ce68204808f9905413fe15843a7cc0f1c56988.tar.gz rails-40ce68204808f9905413fe15843a7cc0f1c56988.tar.bz2 rails-40ce68204808f9905413fe15843a7cc0f1c56988.zip |
made the result set object act more like an array
Diffstat (limited to 'activerecord/lib/active_record/result.rb')
-rw-r--r-- | activerecord/lib/active_record/result.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 9ceab2eabc..68389a21fb 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -24,6 +24,25 @@ module ActiveRecord hash_rows end + alias :map! :map + alias :collect! :map + + def empty? + rows.empty? + end + + def to_ary + hash_rows + end + + def [](idx) + hash_rows[idx] + end + + def last + hash_rows.last + end + private def hash_rows @hash_rows ||= @rows.map { |row| |