Module: HTTPI::Adapter
- Defined in:
- lib/httpi/adapter.rb,
lib/httpi/adapter/base.rb,
lib/httpi/adapter/curb.rb,
lib/httpi/adapter/http.rb,
lib/httpi/adapter/rack.rb,
lib/httpi/adapter/excon.rb,
lib/httpi/adapter/em_http.rb,
lib/httpi/adapter/net_http.rb,
lib/httpi/adapter/httpclient.rb,
lib/httpi/adapter/net_http_persistent.rb
Overview
HTTPI::Adapter
Manages the adapter classes. Currently supports:
-
httpclient
-
curb
-
em_http
-
net/http
Defined Under Namespace
Classes: Base, Curb, EmHttpRequest, Excon, HTTP, HTTPClient, NetHTTP, NetHTTPPersistent, Rack
Constant Summary collapse
- ADAPTERS =
{}
- ADAPTER_CLASS_MAP =
{}
- LOAD_ORDER =
[:httpclient, :curb, :em_http, :excon, :http, :net_http, :net_http_persistent]
Class Attribute Summary collapse
-
.client_setup_block ⇒ Object
Returns the value of attribute client_setup_block.
Class Method Summary collapse
- .identify(adapter_class) ⇒ Object
- .load(adapter) ⇒ Object
- .load_adapter(adapter) ⇒ Object
- .register(name, adapter_class, deps) ⇒ Object
- .use ⇒ Object
- .use=(adapter) ⇒ Object
Class Attribute Details
.client_setup_block ⇒ Object
Returns the value of attribute client_setup_block.
37 38 39 |
# File 'lib/httpi/adapter.rb', line 37 def client_setup_block @client_setup_block end |
Class Method Details
.identify(adapter_class) ⇒ Object
39 40 41 |
# File 'lib/httpi/adapter.rb', line 39 def identify(adapter_class) ADAPTER_CLASS_MAP[adapter_class] end |
.load(adapter) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/httpi/adapter.rb', line 43 def load(adapter) adapter ||= use validate_adapter!(adapter) load_adapter(adapter) ADAPTERS[adapter][:class] end |
.load_adapter(adapter) ⇒ Object
51 52 53 54 55 |
# File 'lib/httpi/adapter.rb', line 51 def load_adapter(adapter) ADAPTERS[adapter][:deps].each do |dep| require dep end end |
.register(name, adapter_class, deps) ⇒ Object
20 21 22 23 |
# File 'lib/httpi/adapter.rb', line 20 def register(name, adapter_class, deps) ADAPTERS[name] = { :class => adapter_class, :deps => deps } ADAPTER_CLASS_MAP[adapter_class] = name end |
.use ⇒ Object
33 34 35 |
# File 'lib/httpi/adapter.rb', line 33 def use @adapter ||= default_adapter end |
.use=(adapter) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/httpi/adapter.rb', line 25 def use=(adapter) return @adapter = nil if adapter.nil? validate_adapter! adapter load_adapter adapter @adapter = adapter end |