18F/identity-idp

View on GitHub
app/models/concerns/non_null_uuid.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

# Default populates a uuid field with a v4 UUID.
module NonNullUuid
  extend ActiveSupport::Concern

  included do
    before_create :generate_uuid
  end

  def generate_uuid
    self.uuid ||= SecureRandom.uuid
  end
end