Sha256: fc4501317c921b3359b87214816067962c8e96bcd99885a0f6fd173e3d90c31e

Contents?: true

Size: 713 Bytes

Versions: 5

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

5 entries across 5 versions & 1 rubygems

Version Path
findable-0.2.2 lib/findable/query/connection.rb
findable-0.2.1 lib/findable/query/connection.rb
findable-0.2.0 lib/findable/query/connection.rb
findable-0.1.5 lib/findable/query/connection.rb
findable-0.1.4 lib/findable/query/connection.rb