Sha256: 76781a88c08e7377386c584d227c39f488ae2f5c2651811612d812e368a6a18d

Contents?: true

Size: 970 Bytes

Versions: 1

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

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

module HellaRedis
  def self.new(args)
    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)
      if other.is_a?(Config)
        url      == other.url      &&
        driver   == other.driver   &&
        redis_ns == other.redis_ns &&
        timeout  == other.timeout  &&
        size     == other.size
      else
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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