Class: Aitch::Configuration
- Inherits:
-
Object
- Object
- Aitch::Configuration
- Defined in:
- lib/aitch/configuration.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Set the base url.
-
#default_headers ⇒ Object
Set default headers.
-
#follow_redirect ⇒ Object
Set follow redirect.
-
#logger ⇒ Object
Set the logger.
-
#proxy ⇒ Object
Set proxy.
-
#redirect_limit ⇒ Object
Set redirection limit.
-
#retries ⇒ Object
Set number of retries.
-
#timeout ⇒ Object
Set request timeout.
-
#user_agent ⇒ Object
Set the user agent.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
43 44 45 46 47 48 49 50 51 |
# File 'lib/aitch/configuration.rb', line 43 def initialize @timeout = 10 @retries = 1 @redirect_limit = 5 @follow_redirect = true @user_agent = "Aitch/#{Aitch::VERSION} (http://rubygems.org/gems/aitch)" @default_headers = Headers.new @base_url = nil end |
Instance Attribute Details
#base_url ⇒ Object
Set the base url.
41 42 43 |
# File 'lib/aitch/configuration.rb', line 41 def base_url @base_url end |
#default_headers ⇒ Object
Set default headers.
12 13 14 |
# File 'lib/aitch/configuration.rb', line 12 def default_headers @default_headers end |
#follow_redirect ⇒ Object
Set follow redirect.
15 16 17 |
# File 'lib/aitch/configuration.rb', line 15 def follow_redirect @follow_redirect end |
#logger ⇒ Object
Set the logger.
38 39 40 |
# File 'lib/aitch/configuration.rb', line 38 def logger @logger end |
#proxy ⇒ Object
Set proxy.
6 7 8 |
# File 'lib/aitch/configuration.rb', line 6 def proxy @proxy end |
#redirect_limit ⇒ Object
Set redirection limit.
18 19 20 |
# File 'lib/aitch/configuration.rb', line 18 def redirect_limit @redirect_limit end |
#retries ⇒ Object
Set number of retries. This will be set as ‘Net::HTTP#max_retries`. Defaults to 1 (ruby’s default). Retries are triggered for the following errors:
- `Net::ReadTimeout`
- `IOError`
- `EOFError`
- `Errno::ECONNRESET`
- `Errno::ECONNABORTED`
- `Errno::EPIPE`
- `OpenSSL::SSL::SSLError`
- `Timeout::Error`
32 33 34 |
# File 'lib/aitch/configuration.rb', line 32 def retries @retries end |
#timeout ⇒ Object
Set request timeout.
9 10 11 |
# File 'lib/aitch/configuration.rb', line 9 def timeout @timeout end |
#user_agent ⇒ Object
Set the user agent.
35 36 37 |
# File 'lib/aitch/configuration.rb', line 35 def user_agent @user_agent end |
Instance Method Details
#to_h ⇒ Object
57 58 59 60 61 |
# File 'lib/aitch/configuration.rb', line 57 def to_h instance_variables.each_with_object({}) do |name, buffer| buffer[name.to_s.tr("@", "").to_sym] = instance_variable_get(name) end end |