Class: ActiveRecord::Turntable::SequencerRegistry
- Inherits:
-
Object
- Object
- ActiveRecord::Turntable::SequencerRegistry
- Defined in:
- lib/active_record/turntable/sequencer_registry.rb
Instance Attribute Summary collapse
-
#sequencers ⇒ Object
(also: #all)
readonly
Returns the value of attribute sequencers.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add(name, type, options, cluster) ⇒ Object
- #cluster_sequencers(cluster) ⇒ Object
-
#initialize ⇒ SequencerRegistry
constructor
A new instance of SequencerRegistry.
- #release! ⇒ Object
Constructor Details
#initialize ⇒ SequencerRegistry
Returns a new instance of SequencerRegistry.
6 7 8 9 |
# File 'lib/active_record/turntable/sequencer_registry.rb', line 6 def initialize @sequencers = {}.with_indifferent_access @cluster_sequencers = {}.with_indifferent_access end |
Instance Attribute Details
#sequencers ⇒ Object (readonly) Also known as: all
Returns the value of attribute sequencers.
3 4 5 |
# File 'lib/active_record/turntable/sequencer_registry.rb', line 3 def sequencers @sequencers end |
Instance Method Details
#[](name) ⇒ Object
22 23 24 |
# File 'lib/active_record/turntable/sequencer_registry.rb', line 22 def [](name) @sequencers[name] end |
#add(name, type, options, cluster) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/active_record/turntable/sequencer_registry.rb', line 11 def add(name, type, , cluster) # TODO: Warn if defined the same name sequencer already. sequencer = (@sequencers[name] ||= Sequencer.class_for(type).new()) @cluster_sequencers[cluster] ||= {}.with_indifferent_access @cluster_sequencers[cluster][name] ||= sequencer end |
#cluster_sequencers(cluster) ⇒ Object
26 27 28 |
# File 'lib/active_record/turntable/sequencer_registry.rb', line 26 def cluster_sequencers(cluster) @cluster_sequencers[cluster] end |
#release! ⇒ Object
18 19 20 |
# File 'lib/active_record/turntable/sequencer_registry.rb', line 18 def release! @sequencers.each(&:release!) end |