2017-07-09 17:49:52 +00:00
|
|
|
# frozen_string_literal: true
|
2017-07-10 13:40:03 +00:00
|
|
|
|
2014-05-19 10:06:09 +00:00
|
|
|
class Person
|
2014-08-17 20:48:44 +00:00
|
|
|
class RecordNotFound < StandardError; end
|
|
|
|
|
2014-08-17 01:06:30 +00:00
|
|
|
include GlobalID::Identification
|
2014-05-19 17:36:41 +00:00
|
|
|
|
2014-05-19 10:06:09 +00:00
|
|
|
attr_reader :id
|
2014-05-19 17:36:41 +00:00
|
|
|
|
2014-05-19 10:06:09 +00:00
|
|
|
def self.find(id)
|
2016-10-29 03:05:58 +00:00
|
|
|
raise RecordNotFound.new("Cannot find person with ID=404") if id.to_i == 404
|
2014-05-19 10:06:09 +00:00
|
|
|
new(id)
|
|
|
|
end
|
2014-05-19 17:36:41 +00:00
|
|
|
|
2014-05-19 10:06:09 +00:00
|
|
|
def initialize(id)
|
|
|
|
@id = id
|
|
|
|
end
|
2014-05-19 17:36:41 +00:00
|
|
|
|
2014-05-19 10:06:09 +00:00
|
|
|
def ==(other_person)
|
2014-05-19 17:36:41 +00:00
|
|
|
other_person.is_a?(Person) && id.to_s == other_person.id.to_s
|
2014-05-19 10:06:09 +00:00
|
|
|
end
|
2014-05-19 17:32:05 +00:00
|
|
|
end
|