Class: Johac::Connection::Middleware::PersistentAdapter
- Inherits:
-
Faraday::Adapter::NetHttpPersistent
- Object
- Faraday::Adapter::NetHttpPersistent
- Johac::Connection::Middleware::PersistentAdapter
- Defined in:
- lib/johac/connection.rb
Overview
Wrapper of Faraday::Adapter::NetHttpPersistent adapter that allows for a block to be given when the faraday connection is created. Block is passed the newly created Net::HTTP::Persistent instance to be modified if desired.
Allows for configuration of HTTP connection.
Instance Method Summary collapse
-
#initialize(app) {|Net::HTTP::Persistent| ... } ⇒ PersistentAdapter
constructor
Extend Faraday::Adapter::NetHttpPersistent’s initialize method with an optional block.
-
#with_net_http_connection(env) {|http| ... } ⇒ Object
Yield HTTP connection to supplied block.
Constructor Details
#initialize(app) {|Net::HTTP::Persistent| ... } ⇒ PersistentAdapter
Extend Faraday::Adapter::NetHttpPersistent’s initialize method with an optional block.
83 84 85 86 |
# File 'lib/johac/connection.rb', line 83 def initialize(app, &block) @config_block = block super(app) end |
Instance Method Details
#with_net_http_connection(env) {|http| ... } ⇒ Object
Yield HTTP connection to supplied block.
89 90 91 92 93 |
# File 'lib/johac/connection.rb', line 89 def with_net_http_connection(env, &block) http = super(env) { |v| v } @config_block.call(http) if @config_block yield http end |