Class: EzClient::Client
- Inherits:
-
Object
- Object
- EzClient::Client
- Defined in:
- lib/ezclient/client.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #perform(*args) ⇒ Object
- #perform!(*args) ⇒ Object
- #request(verb, url, **options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
4 5 6 7 |
# File 'lib/ezclient/client.rb', line 4 def initialize( = {}) self. = self.clients = {} end |
Instance Method Details
#perform(*args) ⇒ Object
26 27 28 |
# File 'lib/ezclient/client.rb', line 26 def perform(*args) request(*args).perform end |
#perform!(*args) ⇒ Object
30 31 32 |
# File 'lib/ezclient/client.rb', line 30 def perform!(*args) request(*args).perform! end |
#request(verb, url, **options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ezclient/client.rb', line 9 def request(verb, url, **) = { **, ** } # TODO: raise on unknown options keep_alive_timeout = .delete(:keep_alive) api_auth = .delete(:api_auth) if keep_alive_timeout client = persistent_client_for(url, timeout: keep_alive_timeout) else client = HTTP::Client.new end EzClient::Request.new(verb, url, client: client, **).tap do |request| request.api_auth!(*api_auth) if api_auth end end |