lib/slavery.rb in slavery-2.0.0 vs lib/slavery.rb in slavery-2.1.0

- old
+ new

@@ -1,49 +1,29 @@ require 'active_record' +require 'slavery/version' require 'slavery/base' require 'slavery/error' -require 'slavery/slave_connection_holder' -require 'slavery/version' +require 'slavery/connection_holder' +require 'slavery/transaction' require 'slavery/active_record/base' +require 'slavery/active_record/connection_handling' require 'slavery/active_record/relation' +require 'slavery/active_record/log_subscriber' module Slavery class << self attr_accessor :disabled attr_writer :spec_key def spec_key - case @spec_key - when String then @spec_key - when NilClass then @spec_key = "#{ActiveRecord::ConnectionHandling::RAILS_ENV.call}_slave" - end + @spec_key ||= "#{ActiveRecord::ConnectionHandling::RAILS_ENV.call}_slave" end def on_slave(&block) Base.new(:slave).run &block end def on_master(&block) Base.new(:master).run &block - end - - def slave_connection_holder - @slave_connection_holder ||= begin - SlaveConnectionHolder.activate - SlaveConnectionHolder - end - end - - def base_transaction_depth - @base_transaction_depth ||= begin - testcase = ActiveSupport::TestCase - if defined?(testcase) && - testcase.respond_to?(:use_transactional_fixtures) && - testcase.try(:use_transactional_fixtures) - 1 - else - 0 - end - end end end end