class DbCharmer::Sharding::Connection

Attributes

config[RW]
sharder[RW]

Public Class Methods

new(config) click to toggle source
# File lib/db_charmer/sharding/connection.rb, line 6
def initialize(config)
  @config = config
  @sharder = self.instantiate_sharder
end

Public Instance Methods

default_connection() click to toggle source
# File lib/db_charmer/sharding/connection.rb, line 26
def default_connection
  @default_connection ||= DbCharmer::Sharding::StubConnection.new(self)
end
instantiate_sharder() click to toggle source
# File lib/db_charmer/sharding/connection.rb, line 11
def instantiate_sharder
  raise ArgumentError, "No :method passed!" unless config[:method]
  sharder_class_name = "DbCharmer::Sharding::Method::#{config[:method].to_s.classify}"
  sharder_class = sharder_class_name.constantize
  sharder_class.new(config)
end
shard_connections() click to toggle source
# File lib/db_charmer/sharding/connection.rb, line 18
def shard_connections
  sharder.respond_to?(:shard_connections) ? sharder.shard_connections : nil
end
support_default_shard?() click to toggle source
# File lib/db_charmer/sharding/connection.rb, line 22
def support_default_shard?
  sharder.respond_to?(:support_default_shard?) && sharder.support_default_shard?
end