Class: Couchbase::ClusterRegistry
- Inherits:
-
Object
- Object
- Couchbase::ClusterRegistry
- Includes:
- Singleton
- Defined in:
- lib/couchbase/cluster_registry.rb,
/code/couchbase-ruby-client/lib/couchbase/cluster_registry.rb
Instance Method Summary collapse
- #connect(connection_string_or_config, *options) ⇒ Object
- #deregister_connection_handler(regexp) ⇒ Object
-
#initialize ⇒ ClusterRegistry
constructor
A new instance of ClusterRegistry.
- #register_connection_handler(regexp, cluster_class) ⇒ Object
Constructor Details
#initialize ⇒ ClusterRegistry
Returns a new instance of ClusterRegistry.
25 26 27 |
# File 'lib/couchbase/cluster_registry.rb', line 25 def initialize @handlers = {} end |
Instance Method Details
#connect(connection_string_or_config, *options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/couchbase/cluster_registry.rb', line 29 def connect(connection_string_or_config, *) connection_string = if connection_string_or_config.is_a?(Configuration) connection_string_or_config.connection_string else connection_string_or_config end @handlers.each do |regexp, cluster_class| return cluster_class.connect(connection_string_or_config, *) if regexp.match?(connection_string) end raise(Error::FeatureNotAvailable, "Connection string '#{connection_string}' not supported.") end |
#deregister_connection_handler(regexp) ⇒ Object
45 46 47 |
# File 'lib/couchbase/cluster_registry.rb', line 45 def deregister_connection_handler(regexp) @handlers.delete(regexp) end |
#register_connection_handler(regexp, cluster_class) ⇒ Object
41 42 43 |
# File 'lib/couchbase/cluster_registry.rb', line 41 def register_connection_handler(regexp, cluster_class) @handlers[regexp] = cluster_class end |