Module: Sequel::ServerBlock
- Defined in:
- lib/sequel/extensions/server_block.rb
Class Method Summary collapse
-
.extended(db) ⇒ Object
Enable the server block on the connection pool, choosing the correct extension depending on whether the connection pool is threaded or not.
Instance Method Summary collapse
-
#with_server(server, &block) ⇒ Object
Delegate to the connection pool.
Class Method Details
.extended(db) ⇒ Object
Enable the server block on the connection pool, choosing the correct extension depending on whether the connection pool is threaded or not. Also defines the with_server method on the receiver for easy use.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sequel/extensions/server_block.rb', line 51 def self.extended(db) pool = db.pool if defined?(ShardedThreadedConnectionPool) && pool.is_a?(ShardedThreadedConnectionPool) pool.extend(ThreadedServerBlock) pool.instance_variable_set(:@default_servers, {}) else pool.extend(UnthreadedServerBlock) pool.instance_variable_set(:@default_servers, []) end end |
Instance Method Details
#with_server(server, &block) ⇒ Object
Delegate to the connection pool
63 64 65 |
# File 'lib/sequel/extensions/server_block.rb', line 63 def with_server(server, &block) pool.with_server(server, &block) end |