Sha256: 08a9f92270edad54abc3f19bc0d564b0392d34f19b7997f3ee2e4b9ef7e021fd

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

require 'active_record'
require 'slavery/version'
require 'slavery/base'
require 'slavery/error'
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
      @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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slavery-2.1.1 lib/slavery.rb
slavery-2.1.0 lib/slavery.rb