aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/models/person.rb
blob: b5d68ad9c18ceff4f08428b68a7d5a0dbbad9cb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Person
  class RecordNotFound < StandardError; end

  include GlobalID::Identification

  attr_reader :id

  def self.find(id)
    raise RecordNotFound.new("Cannot find person with ID=404") if id.to_i == 404
    new(id)
  end

  def initialize(id)
    @id = id
  end

  def ==(other_person)
    other_person.is_a?(Person) && id.to_s == other_person.id.to_s
  end
end