Sha256: 6e73a80b0433fa2c09c83b045a18b449c00d9736250b673f00d5a40c59cfa628

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

#
#= ActiveRecord::Turntable
#
# ActiveRecord Sharding Plugin
#
require 'active_record/turntable/version'
require 'active_record'
require 'active_record/fixtures'
require 'active_support/concern'
require 'active_record/turntable/error'
require 'logger'
require 'singleton'

module ActiveRecord::Turntable
  extend ActiveSupport::Concern
  extend ActiveSupport::Autoload

  eager_autoload do
    autoload :ActiveRecordExt
    autoload :Algorithm
    autoload :Base
    autoload :Cluster
    autoload :Config
    autoload :ConnectionProxy
    autoload :MasterShard
    autoload :Migration
    autoload :Mixer
    autoload :PoolProxy
    autoload :Shard
    autoload :SeqShard
    autoload :Sequencer
  end
  autoload :Rack
  autoload :Helpers

  included do
    include ActiveRecordExt
    include Base
  end

  module ClassMethods
    DEFAULT_PATH = File.dirname(File.dirname(__FILE__))

    def turntable_config_file
      @@turntable_config_file ||=
        File.join(defined?(::Rails) ?
                   ::Rails.root.to_s : DEFAULT_PATH, 'config/turntable.yml')
    end

    def turntable_config_file=(filename)
      @@turntable_config_file = filename
    end

    def turntable_config
      ActiveRecord::Turntable::Config.instance
    end
  end

  def self.rails4?
    ActiveRecord::VERSION::MAJOR == 4
  end

  def self.rails41_later?
    rails4? && ActiveRecord::VERSION::MINOR >= 1
  end

  require "active_record/turntable/railtie" if defined?(Rails)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
activerecord-turntable-2.0.6 lib/active_record/turntable.rb
activerecord-turntable-2.0.5 lib/active_record/turntable.rb
activerecord-turntable-2.0.4 lib/active_record/turntable.rb
activerecord-turntable-2.0.3 lib/active_record/turntable.rb
activerecord-turntable-2.0.2 lib/active_record/turntable.rb
activerecord-turntable-2.0.1 lib/active_record/turntable.rb
activerecord-turntable-2.0.0 lib/active_record/turntable.rb
activerecord-turntable-2.0.0.rc1 lib/active_record/turntable.rb