Sha256: 2e80308b7c680b228b7b78d7b44f563ac9dfc63635cfd9606d35de1fec433f4b
Contents?: true
Size: 751 Bytes
Versions: 1
Compression:
Stored size: 751 Bytes
Contents
# frozen_string_literal: true require "redis" require "track_ballast/error" module TrackBallast # Raised when Redis access is attempted without a configured Redis connection. class NoRedisError < Error; end class << self attr_writer :redis # Internal Redis connection for +TrackBallast+. # # It defaults to the Redis instance configured by the +REDIS_URL+ # environment variable. # # @return [Redis] a Redis connection def redis if @redis @redis elsif ENV["REDIS_URL"] # This will short-circuit to be `@redis` on future runs @redis = Redis.new(url: ENV["REDIS_URL"]) else raise NoRedisError, "TrackBallast.redis is not configured" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
track_ballast-0.2.0.beta1 | lib/track_ballast/redis.rb |