Skip to content

Commit

Permalink
add CollectionProxy#== documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Rodriguez committed May 26, 2012
1 parent f81798d commit bb55f52
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions activerecord/lib/active_record/associations/collection_proxy.rb
Expand Up @@ -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
Expand Down

0 comments on commit bb55f52

Please sign in to comment.