Class: ROM::Factory::Sequences Private
- Inherits:
-
Object
- Object
- ROM::Factory::Sequences
- 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
- #registry ⇒ Object readonly private
Class Method Summary collapse
- .[](relation) ⇒ Object private
Instance Method Summary collapse
-
#initialize ⇒ Sequences
constructor
private
A new instance of Sequences.
- #next(key) ⇒ Object private
- #reset ⇒ Object private
Constructor Details
#initialize ⇒ Sequences
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
#registry ⇒ Object (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 |
#reset ⇒ 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.
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 |