module Sequel::ArbitraryServers
Private Instance Methods
acquire(thread, server)
click to toggle source
If server is a hash, create a new connection for it, and cache it first by thread and then server.
Calls superclass method
# File lib/sequel/extensions/arbitrary_servers.rb 67 def acquire(thread, server) 68 if server.is_a?(Hash) 69 sync{@allocated[thread] ||= {}}[server] = make_new(server) 70 else 71 super 72 end 73 end
owned_connection(thread, server)
click to toggle source
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.[]
Calls superclass method
# File lib/sequel/extensions/arbitrary_servers.rb 78 def owned_connection(thread, server) 79 if server.is_a?(Hash) 80 if a = sync{@allocated[thread]} 81 a[server] 82 end 83 else 84 super 85 end 86 end
pick_server(server)
click to toggle source
If server is a hash, return it directly.
Calls superclass method
# File lib/sequel/extensions/arbitrary_servers.rb 89 def pick_server(server) 90 if server.is_a?(Hash) 91 server 92 else 93 super 94 end 95 end
release(thread, conn, server)
click to toggle source
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.
Calls superclass method
# File lib/sequel/extensions/arbitrary_servers.rb 100 def release(thread, conn, server) 101 if server.is_a?(Hash) 102 a = @allocated[thread] 103 a.delete(server) 104 @allocated.delete(thread) if a.empty? 105 disconnect_connection(conn) 106 else 107 super 108 end 109 end