cartodb-4.42/lib/carto/uuidhelper.rb
2024-04-06 05:25:13 +00:00

18 lines
345 B
Ruby

require 'securerandom'
module Carto
module UUIDHelper
module_function
UUID_REGEXP = Regexp.new("^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})$")
def uuid?(text)
!(Regexp.new(%r{\A#{UUID_REGEXP}\Z}) =~ text).nil?
end
def random_uuid
SecureRandom.uuid
end
end
end