Sha256: 9f6cddf57855eccfd395db5e9108b8715f1ec7ecc5a47beb2709cb5dc2f99faf
Contents?: true
Size: 917 Bytes
Versions: 17
Compression:
Stored size: 917 Bytes
Contents
require Pathname.new(__FILE__).parent.to_s + '/shared_connection_db_helpers' module Marty; module RSpec; module SharedConnection @@classes_to_exclude_from_shared = ['Marty::Log'] mattr_accessor :classes_to_exclude_from_shared EXCL_LAMBDA = lambda { classes_to_exclude_from_shared }.freeze class ActiveRecord::Base mattr_accessor :shared_connection class << self alias_method :orig_connection, :connection end def self.clear_connection @@shared_connection = nil end clear_connection def self.connection EXCL_LAMBDA.call.include?(model_name) ? orig_connection : @@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection } end def self.reset_shared_connection @@shared_connection = ConnectionPool::Wrapper. new(:size => 1) { retrieve_connection } end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems