Class: ROM::Factory::Sequences Private

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rom/factory/sequences.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSequences

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Sequences.



22
23
24
# File 'lib/rom/factory/sequences.rb', line 22

def initialize
  reset
end

Instance Attribute Details

#registryObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/rom/factory/sequences.rb', line 13

def registry
  @registry
end

Class Method Details

.[](relation) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
# File 'lib/rom/factory/sequences.rb', line 16

def self.[](relation)
  key = :"#{relation.gateway}-#{relation.name.dataset}"
  -> { instance.next(key) }
end

Instance Method Details

#next(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/rom/factory/sequences.rb', line 27

def next(key)
  registry.compute(key) { |v| (v || 0).succ }
end

#resetObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
# File 'lib/rom/factory/sequences.rb', line 32

def reset
  @registry = Concurrent::Map.new
  self
end