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.


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

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.


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

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.


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

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.


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

def next(key)
  registry[key] += 1
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.


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

def reset
  @registry = Concurrent::Map.new { |h, k| h[k] = 0 }
  self
end