Sha256: f6bcfd6ac46a27fa3323a51c0cc3b067046152a83511a148cfb03c659bdfccd9

Contents?: true

Size: 713 Bytes

Versions: 2

Compression:

Stored size: 713 Bytes

Contents

module Findable
  class Query
    module Connection
      # Returns current connection or generate connection.
      # @return [Redis] Redis connection
      def redis
        @_redis ||= generate_redis_connection!
      end

      private
        # Generate connection with redis options or default connection.
        # @return [Redis] Redis connection
        def generate_redis_connection!
          redis_options ? Redis.new(*redis_options) : Redis.current
        end

        # Returns redis options from configuration.
        # @return [Hash] Redis options
        # @return [nil] No Redis options
        def redis_options
          Findable.config.redis_options.presence
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
findable-0.1.1 lib/findable/query/connection.rb
findable-0.1.0 lib/findable/query/connection.rb