2014-05-19 06:06:09 -04:00
|
|
|
class Person
|
2014-08-17 16:48:44 -04:00
|
|
|
class RecordNotFound < StandardError; end
|
|
|
|
|
2014-08-16 21:06:30 -04:00
|
|
|
include GlobalID::Identification
|
2014-05-19 13:36:41 -04:00
|
|
|
|
2014-05-19 06:06:09 -04:00
|
|
|
attr_reader :id
|
2014-05-19 13:36:41 -04:00
|
|
|
|
2014-05-19 06:06:09 -04:00
|
|
|
def self.find(id)
|
2016-10-28 23:05:58 -04:00
|
|
|
raise RecordNotFound.new("Cannot find person with ID=404") if id.to_i == 404
|
2014-05-19 06:06:09 -04:00
|
|
|
new(id)
|
|
|
|
end
|
2014-05-19 13:36:41 -04:00
|
|
|
|
2014-05-19 06:06:09 -04:00
|
|
|
def initialize(id)
|
|
|
|
@id = id
|
|
|
|
end
|
2014-05-19 13:36:41 -04:00
|
|
|
|
2014-05-19 06:06:09 -04:00
|
|
|
def ==(other_person)
|
2014-05-19 13:36:41 -04:00
|
|
|
other_person.is_a?(Person) && id.to_s == other_person.id.to_s
|
2014-05-19 06:06:09 -04:00
|
|
|
end
|
2014-05-19 13:32:05 -04:00
|
|
|
end
|