Method: Contracts::Support.unique_id

Defined in:
lib/contracts/support.rb

.unique_idObject

Generates unique id, which can be used as a part of identifier

Example:

Contracts::Support.unique_id   # => "i53u6tiw5hbo"


25
26
27
28
# File 'lib/contracts/support.rb', line 25

def unique_id
  # Consider using SecureRandom.hex here, and benchmark which one is better
  (Time.now.to_f * 1000).to_i.to_s(36) + rand(1_000_000).to_s(36)
end