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
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.
30 31 32 |
# File 'lib/httpi/adapter.rb', line 30 def self.adapters @adapters ||= { :httpclient => HTTPClient, :curb => Curb, :net_http => NetHTTP } end |
.find(adapter) ⇒ Object
Returns an adapter
. Raises an ArgumentError
unless the adapter
exists.
35 36 37 38 |
# File 'lib/httpi/adapter.rb', line 35 def self.find(adapter) validate_adapter! adapter adapters[adapter] end |
.use ⇒ Object
Returns the adapter to use. Defaults to HTTPI::Adapter::DEFAULT
.
19 20 21 |
# File 'lib/httpi/adapter.rb', line 19 def self.use @use ||= DEFAULT end |
.use=(adapter) ⇒ Object
Sets the adapter
to use. Raises an ArgumentError
unless the adapter
exists.
24 25 26 27 |
# File 'lib/httpi/adapter.rb', line 24 def self.use=(adapter) validate_adapter! adapter @use = adapter end |