Class: Clientele::Configuration
- Inherits:
-
BlockParty::Configuration
- Object
- BlockParty::Configuration
- Clientele::Configuration
- Defined in:
- lib/clientele/configuration.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#ensure_trailing_slash ⇒ Object
Returns the value of attribute ensure_trailing_slash.
-
#follow_redirects ⇒ Object
Returns the value of attribute follow_redirects.
-
#hashify_content_type ⇒ Object
Returns the value of attribute hashify_content_type.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
-
#root_url ⇒ Object
Returns the value of attribute root_url.
Instance Method Summary collapse
- #default_connection ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/clientele/configuration.rb', line 11 def initialize self.logger = Logger.new($stdout) self.adapter = Faraday.default_adapter self.headers = {} self.hashify_content_type = /\bjson$/ self.follow_redirects = true self.redirect_limit = 5 self.ensure_trailing_slash = true self.connection = default_connection end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def adapter @adapter end |
#connection ⇒ Object
Returns the value of attribute connection.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def connection @connection end |
#ensure_trailing_slash ⇒ Object
Returns the value of attribute ensure_trailing_slash.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def ensure_trailing_slash @ensure_trailing_slash end |
#follow_redirects ⇒ Object
Returns the value of attribute follow_redirects.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def follow_redirects @follow_redirects end |
#hashify_content_type ⇒ Object
Returns the value of attribute hashify_content_type.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def hashify_content_type @hashify_content_type end |
#headers ⇒ Object
Returns the value of attribute headers.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def headers @headers end |
#logger ⇒ Object
Returns the value of attribute logger.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def logger @logger end |
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def redirect_limit @redirect_limit end |
#root_url ⇒ Object
Returns the value of attribute root_url.
9 10 11 |
# File 'lib/clientele/configuration.rb', line 9 def root_url @root_url end |
Instance Method Details
#default_connection ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/clientele/configuration.rb', line 23 def default_connection Proc.new do |conn, | conn.use FaradayMiddleware::FollowRedirects, limit: [:redirect_limit] if [:follow_redirects] conn.request :url_encoded conn.response :rashify conn.response :logger, [:logger], bodies: true conn.response :json, content_type: [:hashify_content_type], preserve_raw: true conn..params_encoder = [:params_encoder] if [:params_encoder] yield(conn, ) if block_given? conn.adapter [:adapter] if [:adapter] end end |