Sha256: 4ecc5f7096bee49d8e9f495d867df60b6bee69aaf633b46d5c86c4631d42cf7a

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

require 'erb'
require "tako/version"
require "tako/config"
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.create_proxy(shard_name).with_shard do
          yield
        end
      else
        raise "gimme a block!"
      end
    end

    def load_connections_from_yaml
      Tako::Repository.clear
      (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'
require 'tako/active_record_ext/sharded_methods'
require 'tako/active_record_ext/connection_handling'
require 'tako/active_record_ext/base'
require 'tako/active_record_ext/association'
require 'tako/active_record_ext/collection_association'
require 'tako/active_record_ext/singular_association'
require 'tako/active_record_ext/collection_proxy'
require 'tako/active_record_ext/association_relation'
require 'tako/active_record_ext/log_subscriber'

require 'tako/railtie' if defined?(::Rails)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tako-0.6.0 lib/tako.rb
tako-0.5.0 lib/tako.rb
tako-0.4.1 lib/tako.rb
tako-0.4.0 lib/tako.rb
tako-0.3.2 lib/tako.rb
tako-0.3.1 lib/tako.rb