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.
22 23 24 |
# File 'lib/rom/factory/sequences.rb', line 22 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.
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 |
#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.
32 33 34 35 |
# File 'lib/rom/factory/sequences.rb', line 32 def reset @registry = Concurrent::Map.new self end |