Class: Appwrite::ID

Inherits:
Object
  • Object
show all
Defined in:
lib/appwrite/id.rb

Class Method Summary collapse

Class Method Details

.custom(id) ⇒ Object



5
6
7
# File 'lib/appwrite/id.rb', line 5

def self.custom(id)
    id
end

.unique(padding = 7) ⇒ Object

Generate a unique ID with padding to have a longer ID



10
11
12
13
14
15
# File 'lib/appwrite/id.rb', line 10

def self.unique(padding=7)
    base_id = self.hex_timestamp
    random_padding = SecureRandom.hex(padding)
    random_padding = random_padding[0...padding]
    base_id + random_padding
end