Sha256: 02994321294d3db58f0918c3a63f37e0f5d2ff51b7d5170c9998733a9596560c

Contents?: true

Size: 769 Bytes

Versions: 17

Compression:

Stored size: 769 Bytes

Contents

module DbCharmer
  module Sharding
    class Connection
      attr_accessor :config, :sharder

      def initialize(config)
        @config = config
        @sharder = self.instantiate_sharder
      end

      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

      def shard_connections
        sharder.respond_to?(:shard_connections) ? sharder.shard_connections : nil
      end

      def support_default_shard?
        sharder.respond_to?(:support_default_shard?) && sharder.support_default_shard?
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
db-charmer-1.6.16 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.15 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.14 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.13 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.12 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.11 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.10 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.9 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.8 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.7 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.6 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.5 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.4 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.3 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.2 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.1 lib/db_charmer/sharding/connection.rb
db-charmer-1.6.0 lib/db_charmer/sharding/connection.rb