Sha256: c8077413651ef60d653da0b32002c0b7baeee4fee296aa6ba5d6da56718b8091

Contents?: true

Size: 428 Bytes

Versions: 3

Compression:

Stored size: 428 Bytes

Contents

# frozen_string_literal: true
module Aitch
  class Redirect
    attr_reader :tries

    def initialize(options)
      @tries = 1
      @options = options
    end

    def followed!
      @tries += 1
    end

    def follow?(response)
      enabled? && response.redirect? && tries < max_tries
    end

    def max_tries
      @options[:redirect_limit]
    end

    def enabled?
      @options[:follow_redirect]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aitch-1.0.2 lib/aitch/redirect.rb
aitch-1.0.1 lib/aitch/redirect.rb
aitch-1.0.0 lib/aitch/redirect.rb