Sha256: e58623930e1aa362236471d4e3e0819ae048da94821e8c71d635b1797e447133
Contents?: true
Size: 489 Bytes
Versions: 42
Compression:
Stored size: 489 Bytes
Contents
module Virgo module Common module Uuid extend ActiveSupport::Concern included do before_validation :generate_uuid, on: :create private def generate_uuid(opts={}) if uuid.blank? || opts[:force] == true self.uuid = loop do random_uuid = SecureRandom.hex(8) break random_uuid unless self.class.where(uuid: random_uuid).exists? end end end end end end end
Version data entries
42 entries across 42 versions & 1 rubygems