lib/tako.rb in tako-0.1.0 vs lib/tako.rb in tako-0.2.0

- old
+ new

@@ -4,12 +4,15 @@ require "tako/active_record_ext" require "tako/repository" require "tako/proxy_stack" require "tako/proxy" require "tako/query_chain" +require "tako/multi_shard_execution" module Tako + extend MultiShardExecution + class << self def shard(shard_name) if block_given? Tako::Repository.shard(shard_name).in_proxy do yield @@ -17,15 +20,23 @@ else raise "gimme a block!" end end - def load_connections_from_yaml(config = Tako::Config.shards_yml) - (config[:tako][Tako::Config.env] || []).each do |shard_name, conf| + def load_connections_from_yaml + (config[env] || []).each do |shard_name, conf| Tako::Repository.add(shard_name, conf) end end + + def config + Tako::Config.shards_yml[:tako] + end + + def env + Tako::Config.env + end end end require 'active_record' @@ -34,5 +45,7 @@ end ActiveRecord::Base.class_eval do extend Tako::ActiveRecordExt::Base::Extend end + +require 'tako/railtie' if defined?(::Rails)