Sha256: 848159bdbdc8f3ecb71c6f890a7a0a456fe718dfab01c466704d8389185e125c

Contents?: true

Size: 744 Bytes

Versions: 7

Compression:

Stored size: 744 Bytes

Contents

require 'logger'
class RedisLock
  class Configuration
    class RedisNotSet < StandardError; end
    def redis=(hash = {})
      @redis = hash
    end

    def redis
      fail RedisNotSet, "[#{self.class}] redis connection setup is not set" unless @redis
      if @redis.respond_to?(:call)
        return @redis.call
      else
        self.redis_instance = @redis
        @redis_instance
      end
    end


    def logger=(logger)
      @logger = logger
    end

    def logger
      @logger || Logger.new(STDOUT)
    end

    def default_ttl=(val)
      @default_ttl = val
    end

    def default_ttl
      @default_ttl || 60
    end

    private

    def redis_instance=(args)
      @redis_instance ||= Redis.new(args)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
redis_lock-0.4.4 lib/redis_lock/configuration.rb
redis_lock-0.4.3 lib/redis_lock/configuration.rb
redis_lock-0.4.2 lib/redis_lock/configuration.rb
redis_lock-0.3.1 lib/redis_lock/configuration.rb
redis_lock-0.4.1 lib/redis_lock/configuration.rb
redis_lock-0.4.0 lib/redis_lock/configuration.rb
redis_lock-0.3.0 lib/redis_lock/configuration.rb