Permalink
Browse files

add CollectionProxy#== documentation

  • Loading branch information...
1 parent f81798d commit bb55f52ee8ae0eb932eec4eace8adb81b05d13ad Francesco Rodriguez committed May 26, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 activerecord/lib/active_record/associations/collection_proxy.rb
@@ -860,6 +860,30 @@ def scoped(options = nil)
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

0 comments on commit bb55f52

Please sign in to comment.