Class: Contracts::Stringy::UUID

Inherits:
Object
  • Object
show all
Defined in:
lib/contracts/stringy.rb

Overview

A string that looks like a UUID

See Also:

Class Method Summary collapse

Class Method Details

.generate(*_args) ⇒ Object



69
70
71
# File 'lib/contracts/stringy.rb', line 69

def self.generate(*_args)
  SecureRandom.uuid
end

.valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/contracts/stringy.rb', line 65

def self.valid?(value)
  value.is_a? String and (value =~ UUID_REGEX) != nil
end