Class: ActiveRecord::Sharding::Config
- Inherits:
-
Object
- Object
- ActiveRecord::Sharding::Config
- Defined in:
- lib/active_record/sharding/config.rb
Instance Attribute Summary collapse
-
#cluster_configs ⇒ Object
readonly
Returns the value of attribute cluster_configs.
-
#sequencer_configs ⇒ Object
readonly
Returns the value of attribute sequencer_configs.
Instance Method Summary collapse
- #define_cluster(cluster_name, &block) ⇒ Object
- #define_sequencer(sequencer_name, &block) ⇒ Object
- #fetch_cluster_config(cluster_name) ⇒ Object
- #fetch_sequencer_config(sequencer_name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 9 |
# File 'lib/active_record/sharding/config.rb', line 6 def initialize @cluster_configs = {} @sequencer_configs = {} end |
Instance Attribute Details
#cluster_configs ⇒ Object (readonly)
Returns the value of attribute cluster_configs.
4 5 6 |
# File 'lib/active_record/sharding/config.rb', line 4 def cluster_configs @cluster_configs end |
#sequencer_configs ⇒ Object (readonly)
Returns the value of attribute sequencer_configs.
4 5 6 |
# File 'lib/active_record/sharding/config.rb', line 4 def sequencer_configs @sequencer_configs end |
Instance Method Details
#define_cluster(cluster_name, &block) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/active_record/sharding/config.rb', line 11 def define_cluster(cluster_name, &block) cluster_config = ClusterConfig.new(cluster_name) cluster_config.instance_eval(&block) cluster_config.validate_config! @cluster_configs[cluster_name] = cluster_config end |
#define_sequencer(sequencer_name, &block) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/active_record/sharding/config.rb', line 22 def define_sequencer(sequencer_name, &block) sequencer_config = SequencerConfig.new sequencer_name sequencer_config.instance_eval(&block) sequencer_config.validate_config! @sequencer_configs[sequencer_name] = sequencer_config end |
#fetch_cluster_config(cluster_name) ⇒ Object
18 19 20 |
# File 'lib/active_record/sharding/config.rb', line 18 def fetch_cluster_config(cluster_name) @cluster_configs.fetch cluster_name end |
#fetch_sequencer_config(sequencer_name) ⇒ Object
29 30 31 |
# File 'lib/active_record/sharding/config.rb', line 29 def fetch_sequencer_config(sequencer_name) @sequencer_configs.fetch sequencer_name end |