Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add CollectionProxy#== documentation

  • Loading branch information...
commit bb55f52ee8ae0eb932eec4eace8adb81b05d13ad 1 parent f81798d
Francesco Rodríguez frodsan authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 activerecord/lib/active_record/associations/collection_proxy.rb
24 activerecord/lib/active_record/associations/collection_proxy.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.