From 80e31d217e798c2b440732a71e07db1cdc87ff87 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Thu, 20 Sep 2018 12:16:51 +0300 Subject: Make `ActiveRecord::Result#to_a` as alias to `ActiveRecord::Result#to_ary` `ActiveRecord::Result#to_a` was introduced in #33912. I would prefer to make `to_a` as alias to the `to_ary` because: - It would be clear for users from https://edgeapi.rubyonrails.org/classes/ActiveRecord/Result.html that `to_a` and `to_ary` are the same - For us it would take less efforts in case if we needed to change the docs or implementation, since the methods are the same Follow up #33912 --- activerecord/lib/active_record/result.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/result.rb') diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 453331e163..da6d10b6ec 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -65,11 +65,6 @@ module ActiveRecord end end - # Returns an array of hashes representing each row record. - def to_a - hash_rows - end - def to_hash ActiveSupport::Deprecation.warn(<<-MSG.squish) `ActiveRecord::Result#to_hash` has been renamed to `to_a`. @@ -91,6 +86,8 @@ module ActiveRecord hash_rows end + alias :to_a :to_ary + def [](idx) hash_rows[idx] end -- cgit v1.2.3