aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-25 23:01:38 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-25 23:01:38 -0500
commitbb55f52ee8ae0eb932eec4eace8adb81b05d13ad (patch)
tree09700217df71577c65b06f03d02e31f2f38c2e96 /activerecord/lib/active_record
parentf81798d06415c538f5b1c5acfd4889b45473e62d (diff)
downloadrails-bb55f52ee8ae0eb932eec4eace8adb81b05d13ad.tar.gz
rails-bb55f52ee8ae0eb932eec4eace8adb81b05d13ad.tar.bz2
rails-bb55f52ee8ae0eb932eec4eace8adb81b05d13ad.zip
add CollectionProxy#== documentation
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index 93ed2e5a56..44f5041bd8 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -860,6 +860,30 @@ module ActiveRecord
end
end
+ # Equivalent to <tt>Array#==</tt>. Returns +true+ if the two arrays
+ # contain the same number of elements and if each element is equal
+ # to the corresponding element in the other array, otherwise returns
+ # +false+.
+ #
+ # class Person < ActiveRecord::Base
+ # has_many :pets
+ # end
+ #
+ # person.pets
+ # # => [
+ # # #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
+ # # #<Pet id: 2, name: "Spook", person_id: 1>
+ # # ]
+ #
+ # other = person.pets.to_ary
+ #
+ # person.pets == other
+ # # => true
+ #
+ # other = [Pet.new(id: 1), Pet.new(id: 2)]
+ #
+ # person.pets == other
+ # # => false
def ==(other)
load_target == other
end