Class: Namira::Config
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Namira::Config
- Defined in:
- lib/namira/config.rb
Overview
Instance Attribute Summary collapse
-
#backend ⇒ Namira::Backend
The backend Namira will use to send the request.
-
#headers ⇒ OpenStruct
readonly
Default headers to send with each request.
-
#log_requests ⇒ Bool
Log requests using puts or Rails.logger.debug if it’s defined.
-
#max_redirect ⇒ Integer
The maximum number of redirects to follow before throwing a Errors::RedirectError.
-
#timeout ⇒ Float
The max length of time (in seconds) Namira will wait before canceling the request and throwing a Errors::TimeoutError.
-
#user_agent ⇒ String
The string to send for the “User-Agent” header.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
57 58 59 |
# File 'lib/namira/config.rb', line 57 def initialize super(DEFAULT_SETTINGS) end |
Instance Attribute Details
#backend ⇒ Namira::Backend
The backend Namira will use to send the request.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/namira/config.rb', line 38 class Config < OpenStruct ## # The # attr_accessor :max_redirect # attr_accessor :timeout # attr_accessor :backend # attr_accessor :user_agent DEFAULT_SETTINGS = { max_redirect: 3, timeout: 5.0, backend: nil, user_agent: "Namira/#{Namira::VERSION}", headers: OpenStruct.new, log_requests: true }.freeze private_constant :DEFAULT_SETTINGS def initialize super(DEFAULT_SETTINGS) end end |
#headers ⇒ OpenStruct (readonly)
Default headers to send with each request
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/namira/config.rb', line 38 class Config < OpenStruct ## # The # attr_accessor :max_redirect # attr_accessor :timeout # attr_accessor :backend # attr_accessor :user_agent DEFAULT_SETTINGS = { max_redirect: 3, timeout: 5.0, backend: nil, user_agent: "Namira/#{Namira::VERSION}", headers: OpenStruct.new, log_requests: true }.freeze private_constant :DEFAULT_SETTINGS def initialize super(DEFAULT_SETTINGS) end end |
#log_requests ⇒ Bool
Log requests using puts or Rails.logger.debug if it’s defined
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/namira/config.rb', line 38 class Config < OpenStruct ## # The # attr_accessor :max_redirect # attr_accessor :timeout # attr_accessor :backend # attr_accessor :user_agent DEFAULT_SETTINGS = { max_redirect: 3, timeout: 5.0, backend: nil, user_agent: "Namira/#{Namira::VERSION}", headers: OpenStruct.new, log_requests: true }.freeze private_constant :DEFAULT_SETTINGS def initialize super(DEFAULT_SETTINGS) end end |
#max_redirect ⇒ Integer
The maximum number of redirects to follow before throwing a Errors::RedirectError
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/namira/config.rb', line 38 class Config < OpenStruct ## # The # attr_accessor :max_redirect # attr_accessor :timeout # attr_accessor :backend # attr_accessor :user_agent DEFAULT_SETTINGS = { max_redirect: 3, timeout: 5.0, backend: nil, user_agent: "Namira/#{Namira::VERSION}", headers: OpenStruct.new, log_requests: true }.freeze private_constant :DEFAULT_SETTINGS def initialize super(DEFAULT_SETTINGS) end end |
#timeout ⇒ Float
The max length of time (in seconds) Namira will wait before canceling the request and throwing a Errors::TimeoutError
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/namira/config.rb', line 38 class Config < OpenStruct ## # The # attr_accessor :max_redirect # attr_accessor :timeout # attr_accessor :backend # attr_accessor :user_agent DEFAULT_SETTINGS = { max_redirect: 3, timeout: 5.0, backend: nil, user_agent: "Namira/#{Namira::VERSION}", headers: OpenStruct.new, log_requests: true }.freeze private_constant :DEFAULT_SETTINGS def initialize super(DEFAULT_SETTINGS) end end |
#user_agent ⇒ String
The string to send for the “User-Agent” header. The value set here will be overriden if a user agent is specified on the request itself.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/namira/config.rb', line 38 class Config < OpenStruct ## # The # attr_accessor :max_redirect # attr_accessor :timeout # attr_accessor :backend # attr_accessor :user_agent DEFAULT_SETTINGS = { max_redirect: 3, timeout: 5.0, backend: nil, user_agent: "Namira/#{Namira::VERSION}", headers: OpenStruct.new, log_requests: true }.freeze private_constant :DEFAULT_SETTINGS def initialize super(DEFAULT_SETTINGS) end end |