29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/db_charmer/active_record/multi_db_proxy.rb', line 29
def on_db(con, proxy_target = nil)
proxy_target ||= self
if self.respond_to? :set_schema_table_name_prefix
self.set_schema_table_name_prefix(con)
end
return OnDbProxy.new(proxy_target, con) unless block_given?
begin
self.db_charmer_connection_level += 1
old_proxy = db_charmer_connection_proxy
switch_connection_to(con, DbCharmer.connections_should_exist?)
yield(proxy_target)
ensure
switch_connection_to(old_proxy)
self.db_charmer_connection_level -= 1
end
end
|