Method: ActiveRecord::Core#hash

Defined in:
activerecord/lib/active_record/core.rb

#hashObject

Delegates to id in order to allow two records of the same type and id to work with something like:

[ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]


641
642
643
644
645
646
647
648
649
# File 'activerecord/lib/active_record/core.rb', line 641

def hash
  id = self.id

  if primary_key_values_present?
    self.class.hash ^ id.hash
  else
    super
  end
end