Class: Vident::StableId
- Inherits:
-
Object
- Object
- Vident::StableId
- Defined in:
- lib/vident/stable_id.rb
Class Method Summary collapse
- .clear_current_sequence_generator ⇒ Object
- .next_id_in_sequence ⇒ Object
- .set_current_sequence_generator ⇒ Object (also: new_current_sequence_generator)
Class Method Details
.clear_current_sequence_generator ⇒ Object
19 20 21 |
# File 'lib/vident/stable_id.rb', line 19 def clear_current_sequence_generator ::Thread.current[:vident_number_sequence_generator] = nil end |
.next_id_in_sequence ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/vident/stable_id.rb', line 23 def next_id_in_sequence generator = ::Thread.current[:vident_number_sequence_generator] # When no generator exists, use a random value. This means we loose the stability of the ID sequence but # at least generate unique IDs for the current render. return Random.hex(16) unless generator generator.next.join("-") end |
.set_current_sequence_generator ⇒ Object Also known as: new_current_sequence_generator
14 15 16 |
# File 'lib/vident/stable_id.rb', line 14 def set_current_sequence_generator ::Thread.current[:vident_number_sequence_generator] = id_sequence_generator end |