Module: HTTPI::Adapter
- Defined in:
- lib/httpi/adapter.rb,
lib/httpi/adapter/curb.rb,
lib/httpi/adapter/net_http.rb,
lib/httpi/adapter/httpclient.rb
Overview
HTTPI::Adapter
Manages the adapter classes. Currently supports:
-
httpclient
-
curb
Defined Under Namespace
Classes: Curb, HTTPClient, NetHTTP
Constant Summary collapse
- DEFAULT =
The default adapter.
:httpclient
- FALLBACK =
The fallback (worst-choice) adapter.
:net_http
Class Method Summary collapse
-
.adapters ⇒ Object
Returns a memoized
Hash
of adapters. -
.find(adapter) ⇒ Object
Returns an
adapter
. -
.use ⇒ Object
Returns the adapter to use.
-
.use=(adapter) ⇒ Object
Sets the
adapter
to use.
Class Method Details
.adapters ⇒ Object
Returns a memoized Hash
of adapters.
33 34 35 36 37 38 39 |
# File 'lib/httpi/adapter.rb', line 33 def self.adapters @adapters ||= { :httpclient => { :class => HTTPClient, :require => "httpclient" }, :curb => { :class => Curb, :require => "curb" }, :net_http => { :class => NetHTTP, :require => "net/https" } } end |
.find(adapter) ⇒ Object
Returns an adapter
. Raises an ArgumentError
unless the adapter
exists.
42 43 44 45 |
# File 'lib/httpi/adapter.rb', line 42 def self.find(adapter) validate_adapter! adapter load_adapter adapter end |
.use ⇒ Object
Returns the adapter to use. Defaults to HTTPI::Adapter::DEFAULT
.
22 23 24 |
# File 'lib/httpi/adapter.rb', line 22 def self.use @use ||= DEFAULT end |
.use=(adapter) ⇒ Object
Sets the adapter
to use. Raises an ArgumentError
unless the adapter
exists.
27 28 29 30 |
# File 'lib/httpi/adapter.rb', line 27 def self.use=(adapter) validate_adapter! adapter @use = adapter end |