app/mixins/duplicate_checking.rb
# Return the ultimate master for a record, which may be the record itself.
Return the ultimate master for a record, which may be the record itself.
Return the ultimate master for a record which may be the record itself .
def progenitor
    parent = self
    seen = Set.new
    while true
      if parent.master?
        return parent
      else
        if seen.include?(parent)
          raise DuplicateCheckingError, "Loop detected in duplicates chain at #{parent.class}##{parent.id}"
        else
          seen << parent
          parent = parent.duplicate_of
        end
      end
    end
  end
def progenitor parent = self seen = Set . new while true if parent . master? return parent else if seen . include? ( parent ) raise DuplicateCheckingError , "Loop detected in duplicates chain at #{parent.class}##{parent.id}" else seen << parent parent = parent . duplicate_of end end end end
Return the ultimate master for a record, which may be the record itself.
Return the ultimate master for a record which may be the record itself .