Class: Aitch::Redirect
Instance Attribute Summary collapse
-
#tries ⇒ Object
readonly
Returns the value of attribute tries.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #follow?(response) ⇒ Boolean
- #followed! ⇒ Object
-
#initialize(options) ⇒ Redirect
constructor
A new instance of Redirect.
- #max_tries ⇒ Object
Constructor Details
#initialize(options) ⇒ Redirect
Returns a new instance of Redirect.
7 8 9 10 |
# File 'lib/aitch/redirect.rb', line 7 def initialize() @tries = 1 @options = end |
Instance Attribute Details
#tries ⇒ Object (readonly)
Returns the value of attribute tries.
5 6 7 |
# File 'lib/aitch/redirect.rb', line 5 def tries @tries end |
Instance Method Details
#enabled? ⇒ Boolean
24 25 26 |
# File 'lib/aitch/redirect.rb', line 24 def enabled? @options[:follow_redirect] end |
#follow?(response) ⇒ Boolean
16 17 18 |
# File 'lib/aitch/redirect.rb', line 16 def follow?(response) enabled? && response.redirect? && tries < max_tries end |
#followed! ⇒ Object
12 13 14 |
# File 'lib/aitch/redirect.rb', line 12 def followed! @tries += 1 end |
#max_tries ⇒ Object
20 21 22 |
# File 'lib/aitch/redirect.rb', line 20 def max_tries @options[:redirect_limit] end |