Sha256: c0d42de73bbb10816d124cb5ae42974467258b0d5ac98dbac74b8f09e2ed87ce
Contents?: true
Size: 841 Bytes
Versions: 12
Compression:
Stored size: 841 Bytes
Contents
module DbCharmer module ConnectionSwitch module ClassMethods def coerce_to_connection_proxy(conn, should_exist = true) return nil if conn.nil? if conn.kind_of?(Symbol) || conn.kind_of?(String) return DbCharmer::ConnectionFactory.connect(conn, should_exist) end if conn.respond_to?(:db_charmer_connection_proxy) return conn.db_charmer_connection_proxy end if conn.kind_of?(ActiveRecord::ConnectionAdapters::AbstractAdapter) return conn end raise "Unsupported connection type: #{conn.class}" end def switch_connection_to(conn, require_config_to_exist = true) self.db_charmer_connection_proxy = coerce_to_connection_proxy(conn, require_config_to_exist) self.hijack_connection! end end end end
Version data entries
12 entries across 12 versions & 1 rubygems