Module: RDF::Util::UUID

Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-c7356a6367f8/lib/rdf/util/uuid.rb

Overview

Utilities for UUID handling.

Class Method Summary collapse

Class Method Details

.generate(format: :default) ⇒ String

Generates a UUID string.

This will make use of either the UUID gem or the UUIDTools gem, whichever of the two happens to be available.

Parameters:

  • format (:default, :compact, :urn)

    (:default)

Returns:

Raises:

  • (LoadError)

    if no UUID library is available

See Also:



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-c7356a6367f8/lib/rdf/util/uuid.rb', line 21

def self.generate(format: :default)
  begin
    require 'uuid'
    ::UUID.generate(format)
  rescue LoadError => e
    begin
      require 'uuidtools'
      ::UUIDTools::UUID.random_create.hexdigest
    rescue LoadError => e
      raise LoadError.new("no such file to load -- uuid or uuidtools")
    end
  end
end