Class: Dbd::Helpers::UUID

Inherits:
Object
  • Object
show all
Defined in:
lib/dbd/helpers/uuid.rb

Overview

A simple UUID implementation based on SecureRandom.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid

Store a SecureRandom.uuid.



20
21
22
# File 'lib/dbd/helpers/uuid.rb', line 20

def initialize
  @uuid = SecureRandom.uuid.encode('utf-8')
end

Class Method Details

.valid_regexpRegexp

A regexp that can be used in tests.

Returns:

  • (Regexp)


13
14
15
# File 'lib/dbd/helpers/uuid.rb', line 13

def self.valid_regexp
  /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\Z/
end

Instance Method Details

#to_sString

The to_s of the uuid.

Returns:

  • (String)


27
28
29
# File 'lib/dbd/helpers/uuid.rb', line 27

def to_s
  @uuid
end