Module: HTTPI::Adapter
- Defined in:
- lib/httpi/adapter.rb,
lib/httpi/adapter/base.rb,
lib/httpi/adapter/curb.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, HTTPClient, NetHTTP, NetHTTPPersistent, Rack
Constant Summary
collapse
- ADAPTERS =
{}
- ADAPTER_CLASS_MAP =
{}
- LOAD_ORDER =
[:httpclient, :curb, :em_http, :excon, :net_http, :net_http_persistent]
Class Method Summary
collapse
Class Method Details
.identify(adapter_class) ⇒ Object
37
38
39
|
# File 'lib/httpi/adapter.rb', line 37
def identify(adapter_class)
ADAPTER_CLASS_MAP[adapter_class]
end
|
.load(adapter) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/httpi/adapter.rb', line 41
def load(adapter)
adapter ||= use
validate_adapter!(adapter)
load_adapter(adapter)
ADAPTERS[adapter][:class]
end
|
.load_adapter(adapter) ⇒ Object
49
50
51
52
53
|
# File 'lib/httpi/adapter.rb', line 49
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
|