Module: Sequel::ServerBlock

Defined in:
lib/sequel/extensions/server_block.rb

Class Method Summary collapse

Instance Method Summary collapse

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.



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/sequel/extensions/server_block.rb', line 70

def self.extended(db)
  pool = db.pool
  case pool.pool_type
  when :sharded_threaded, :sharded_timed_queue
    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(default_server, read_only_server = default_server, &block) ⇒ Object

Delegate to the connection pool



83
84
85
# File 'lib/sequel/extensions/server_block.rb', line 83

def with_server(default_server, read_only_server=default_server, &block)
  pool.with_server(default_server, read_only_server, &block)
end