Class: Dbd::Helpers::UUID
- Inherits:
-
Object
- Object
- Dbd::Helpers::UUID
- Defined in:
- lib/dbd/helpers/uuid.rb
Overview
A simple UUID implementation based on SecureRandom.
Class Method Summary collapse
-
.valid_regexp ⇒ Regexp
A regexp that can be used in tests.
Instance Method Summary collapse
-
#initialize ⇒ void
constructor
Store a SecureRandom.uuid.
-
#to_s ⇒ String
The to_s of the uuid.
Constructor Details
#initialize ⇒ void
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_regexp ⇒ Regexp
A regexp that can be used in tests.
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_s ⇒ String
The to_s of the uuid.
27 28 29 |
# File 'lib/dbd/helpers/uuid.rb', line 27 def to_s @uuid end |