Last active
January 22, 2019 13:45
-
-
Save dhenze/b97be08e1972bfb06cb46a66c72ac1aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "securerandom" | |
class OrderId | |
attr_reader :id | |
def initialize(id) | |
fail TypeError.new("String required") unless id.is_a?(String) | |
@id = id | |
end | |
def self.generate_new | |
new(SecureRandom.uuid) | |
end | |
def equals(other) | |
self.id == (other.id) | |
end | |
def to_s | |
"#{id}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment