Sha256: 6edbe1110b57df8e7ef816de02dad2230347ac8f462a2f3054eeb39d3ce62c2a

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 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 "active_record/turntable/util"
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 :ClusterHelperMethods
    autoload :Config
    autoload :ConnectionProxy
    autoload :MasterShard
    autoload :Migration
    autoload :Mixer
    autoload :PoolProxy
    autoload :Shard
    autoload :ShardingCondition
    autoload :SeqShard
    autoload :Sequencer
  end

  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(turntable_app_root_path, "config/turntable.yml")
    end

    def turntable_config_file=(filename)
      @turntable_config_file = filename
    end

    def turntable_app_root_path
      defined?(::Rails.root) ? ::Rails.root.to_s : DEFAULT_PATH
    end

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

    def turntable_connection_classes
      ActiveRecord::Turntable::Shard.connection_classes
    end
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-turntable-3.0.1 lib/active_record/turntable.rb