Module: Textus::Uid
- Defined in:
- lib/textus/uid.rb
Overview
A Textus UID: 16 lowercase hex chars (SecureRandom.hex(8)). Not a UUID —short on purpose. Random enough for collision-never-in-practice within a single store.
Class Method Summary collapse
Class Method Details
.mint ⇒ Object
10 11 12 |
# File 'lib/textus/uid.rb', line 10 def mint SecureRandom.hex(8) end |
.valid?(str) ⇒ Boolean
14 15 16 |
# File 'lib/textus/uid.rb', line 14 def valid?(str) str.is_a?(String) && str.match?(/\A[0-9a-f]{16}\z/) end |