Class: ActiveRecord::Sharding::ClusterConfig
- Inherits:
-
Object
- Object
- ActiveRecord::Sharding::ClusterConfig
- Defined in:
- lib/active_record/sharding/cluster_config.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #connections ⇒ Object
- #fetch(modulo_key) ⇒ Object
-
#initialize(name) ⇒ ClusterConfig
constructor
A new instance of ClusterConfig.
- #register_connection(connection_name) ⇒ Object
- #registerd_connection_count ⇒ Object
- #validate_config! ⇒ Object
Constructor Details
#initialize(name) ⇒ ClusterConfig
Returns a new instance of ClusterConfig.
6 7 8 9 |
# File 'lib/active_record/sharding/cluster_config.rb', line 6 def initialize(name) @name = name @connection_registry = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/active_record/sharding/cluster_config.rb', line 4 def name @name end |
Instance Method Details
#connections ⇒ Object
27 28 29 |
# File 'lib/active_record/sharding/cluster_config.rb', line 27 def connections @connection_registry end |
#fetch(modulo_key) ⇒ Object
15 16 17 |
# File 'lib/active_record/sharding/cluster_config.rb', line 15 def fetch(modulo_key) @connection_registry[modulo_key] end |
#register_connection(connection_name) ⇒ Object
11 12 13 |
# File 'lib/active_record/sharding/cluster_config.rb', line 11 def register_connection(connection_name) @connection_registry << connection_name end |
#registerd_connection_count ⇒ Object
19 20 21 |
# File 'lib/active_record/sharding/cluster_config.rb', line 19 def registerd_connection_count @connection_registry.count end |
#validate_config! ⇒ Object
23 24 25 |
# File 'lib/active_record/sharding/cluster_config.rb', line 23 def validate_config! raise "Nothing registerd connections." if registerd_connection_count == 0 end |