class SimpleEventSourcing::Id::UUIDId

Public Class Methods

generate() click to toggle source
# File lib/simple_event_sourcing/aggregate_root/id.rb, line 32
def self.generate
  new SecureRandom.uuid
end
new(value) click to toggle source
Calls superclass method SimpleEventSourcing::Id::BaseId::new
# File lib/simple_event_sourcing/aggregate_root/id.rb, line 27
def initialize(value)
  raise UUIDValidationError unless valid? value
  super(value)
end

Private Instance Methods

valid?(uuid) click to toggle source
# File lib/simple_event_sourcing/aggregate_root/id.rb, line 38
def valid?(uuid)
  uuid_regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
  return true if uuid_regex =~ uuid.to_s.downcase
  return false
end