If server is a hash, create a new connection for it, and cache it first by thread and then server.
# File lib/sequel/extensions/arbitrary_servers.rb, line 64 64: def acquire(thread, server) 65: if server.is_a?(Hash) 66: sync{@allocated[thread] ||= {}}[server] = make_new(server) 67: else 68: super 69: end 70: end
If server is a hash, the entry for it probably doesn’t exist in the @allocated hash, so check for existence to avoid calling nil.[]
# File lib/sequel/extensions/arbitrary_servers.rb, line 75 75: def owned_connection(thread, server) 76: if server.is_a?(Hash) 77: if a = sync{@allocated[thread]} 78: a[server] 79: end 80: else 81: super 82: end 83: end
If server is a hash, return it directly.
# File lib/sequel/extensions/arbitrary_servers.rb, line 86 86: def pick_server(server) 87: if server.is_a?(Hash) 88: server 89: else 90: super 91: end 92: end
If server is a hash, delete the thread from the allocated connections for that server. Additionally, if this was the last thread using that server, delete the server from the @allocated hash.
# File lib/sequel/extensions/arbitrary_servers.rb, line 97 97: def release(thread, conn, server) 98: if server.is_a?(Hash) 99: a = @allocated[thread] 100: a.delete(server) 101: @allocated.delete(thread) if a.empty? 102: @disconnection_proc.call(conn) if @disconnection_proc 103: else 104: super 105: end 106: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.