aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-08-19 02:44:45 -0300
committerGitHub <noreply@github.com>2016-08-19 02:44:45 -0300
commita0d24a9c4dfcebb34d5b09220d4b00952ae2d080 (patch)
tree66cbbc1c8099fb41ca8a1da97f1a1358a90070f9 /activerecord
parent544d44fb53616ecf475d24b3e395cb9a07e0a70b (diff)
parentdea671b5e0369f2cd0e9f3c88e6eef7230176b0d (diff)
downloadrails-a0d24a9c4dfcebb34d5b09220d4b00952ae2d080.tar.gz
rails-a0d24a9c4dfcebb34d5b09220d4b00952ae2d080.tar.bz2
rails-a0d24a9c4dfcebb34d5b09220d4b00952ae2d080.zip
Merge pull request #26218 from kamipo/remove_unnecessary_length
Remove unnecessary `length` method for collection proxy
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb9
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb9
2 files changed, 6 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index e17ca81867..a02ec032a7 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -270,15 +270,6 @@ module ActiveRecord
end
end
- # Returns the size of the collection calling +size+ on the target.
- #
- # If the collection has been already loaded +length+ and +size+ are
- # equivalent. If not and you are going to need the records anyway this
- # method will take one less query. Otherwise +size+ is more efficient.
- def length
- load_target.size
- end
-
# Returns true if the collection is empty.
#
# If the collection has been loaded
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index 926defbb47..ffdd1c04a3 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -802,6 +802,12 @@ module ActiveRecord
@association.size
end
+ ##
+ # :method: length
+ #
+ # :call-seq:
+ # length()
+ #
# Returns the size of the collection calling +size+ on the target.
# If the collection has been already loaded, +length+ and +size+ are
# equivalent. If not and you are going to need the records anyway this
@@ -822,9 +828,6 @@ module ActiveRecord
# # #<Pet id: 2, name: "Spook", person_id: 1>,
# # #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# # ]
- def length
- @association.length
- end
# Returns +true+ if the collection is empty. If the collection has been
# loaded it is equivalent