Sha256: b1503a4047ebe81a42f6317c093e180be42fdf078c757adf7e6e9f13ad7e8f9c

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'hella-redis/version'
require 'hella-redis/connection_pool'
require 'hella-redis/connection_pool_spy'

module HellaRedis

  def self.new(args)
    self.send(ENV['HELLA_REDIS_TEST_MODE'] ? :mock : :real, args)
  end

  def self.real(args)
    ConnectionPool.new(Config.new(args))
  end

  def self.mock(args)
    ConnectionPoolSpy.new(Config.new(args))
  end

  class Config

    attr_reader :url, :driver, :redis_ns, :timeout, :size

    def initialize(args = nil)
      args ||= {}
      @url      = args[:url]
      @driver   = args[:driver]
      @redis_ns = args[:redis_ns]
      @timeout  = args[:timeout]
      @size     = args[:size] || 1
    end

    def ==(other_config)
      if other_config.kind_of?(Config)
        self.url      == other_config.url      &&
        self.driver   == other_config.driver   &&
        self.redis_ns == other_config.redis_ns &&
        self.timeout  == other_config.timeout  &&
        self.size     == other_config.size
      else
        super
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hella-redis-0.4.0 lib/hella-redis.rb