Class: Wee::IdGenerator::Sequential

Inherits:
Wee::IdGenerator show all
Defined in:
lib/wee/id_generator.rb

Overview

Sequential id generator.

Returned ids are guaranteed to be unique, but they are easily guessable.

Instance Method Summary collapse

Constructor Details

#initialize(initial_value = 0) ⇒ Sequential

Returns a new instance of Sequential.



18
19
20
# File 'lib/wee/id_generator.rb', line 18

def initialize(initial_value=0)
  @value = initial_value - 1
end

Instance Method Details

#nextObject



22
23
24
# File 'lib/wee/id_generator.rb', line 22

def next
  (@value += 1).to_s(36)
end