module ActiveRecordShards::Tasks

Public Class Methods

root_connection(conf) click to toggle source
# File lib/active_record_shards/tasks.rb, line 96
def root_connection(conf)
  conf = conf.merge('database' => nil)
  spec = spec_for(conf)

  ActiveRecord::Base.send("#{conf['adapter']}_connection", spec.config)
end

Private Class Methods

spec_for(conf) click to toggle source
# File lib/active_record_shards/tasks.rb, line 105
def spec_for(conf)
  resolver = ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(ActiveRecord::Base.configurations)
  resolver.spec(conf)
end