Sha256: 2be3c190ad8707eefcb6b7a2f31a2c63917d83b4684824a2ba2ef6cb58c7ef66
Contents?: true
Size: 805 Bytes
Versions: 3
Compression:
Stored size: 805 Bytes
Contents
module Tako class Repository class << self def proxy_configs @proxy_configs ||= {} end def proxy_connections @proxy_connections ||= {} end def add(shard_name, conf) shard_name = shard_name.to_sym return if proxy_configs[shard_name] temporary_class = Class.new(ActiveRecord::Base) const_set("TAKO_AR_CLASS_#{shard_name.upcase}", temporary_class) temporary_class.establish_connection(conf) proxy_connections[shard_name] = temporary_class.connection proxy_configs[shard_name] = conf end def shard(shard_name, base = nil) Proxy.new(shard_name, proxy_connections[shard_name.to_sym], base) end def shard_names proxy_configs.keys end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tako-0.2.2 | lib/tako/repository.rb |
tako-0.2.1 | lib/tako/repository.rb |
tako-0.2.0 | lib/tako/repository.rb |