lib/ezclient/client.rb in ezclient-0.6.1 vs lib/ezclient/client.rb in ezclient-0.7.0
- old
+ new
@@ -5,11 +5,11 @@
self.options = options
self.clients = {}
end
def request(verb, url, **options)
- options = { **default_options, **options }
+ options = { **default_options, **options } # TODO: raise on unknown options
keep_alive_timeout = options.delete(:keep_alive)
api_auth = options.delete(:api_auth)
if keep_alive_timeout
@@ -39,16 +39,20 @@
uri = HTTP::URI.parse(url)
clients[uri.origin] ||= HTTP.persistent(uri.origin, timeout: timeout)
end
def default_options
- {
- api_auth: options[:api_auth],
- keep_alive: options[:keep_alive],
- max_retries: options[:max_retries],
- on_complete: options[:on_complete],
- on_error: options[:on_error],
- retry_exceptions: options[:retry_exceptions],
- timeout: options[:default_timeout],
- }
+ keys = %i[
+ api_auth
+ keep_alive
+ max_retries
+ on_complete
+ on_error
+ retry_exceptions
+ ssl_context
+ timeout
+ ]
+
+ # RUBY25: Hash#slice
+ options.select { |key| keys.include?(key) }
end
end