Sha256: 7199f3a87c02cb4663835692b15a4e5890b4355b291fef7dcb7897ddee80791e

Contents?: true

Size: 629 Bytes

Versions: 3

Compression:

Stored size: 629 Bytes

Contents

module Hari
  module Configuration
    module Redis

      def redis
        @redis || begin
          self.redis = 'localhost:6379'
          @redis
        end
      end

      def redis=(server)
        @redis = redis_namespace(server)
      end

      private

      def redis_namespace(server)
        return server if server.kind_of?(::Redis::Namespace)

        ::Redis::Namespace.new :hari, redis_server(server)
      end

      def redis_server(server)
        return server unless server.kind_of?(::String)

        host, port = server.split(':')
        ::Redis.new host: host, port: port
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hari-0.0.4 lib/hari/configuration/redis.rb
hari-0.0.3 lib/hari/configuration/redis.rb
hari-0.0.1 lib/hari/configuration/redis.rb