Class: ChimeraHttpClient::Queue
- Inherits:
-
Base
- Object
- Base
- ChimeraHttpClient::Queue
show all
- Defined in:
- lib/chimera_http_client/queue.rb
Constant Summary
Constants inherited
from Base
Base::USER_AGENT
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#add(method, endpoint, options = {}) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/chimera_http_client/queue.rb', line 3
def add(method, endpoint, options = {})
http_method = method.downcase.to_sym
options[:body_optional] = true if %i(get delete head options trace).include?(http_method)
queued_requests << create_request(
method: http_method,
url: url(endpoint),
body: extract_body(options),
headers: (options, ),
options: augmented_options(options)
)
end
|
#empty ⇒ Object
30
31
32
|
# File 'lib/chimera_http_client/queue.rb', line 30
def empty
@queued_requests = []
end
|
#execute ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/chimera_http_client/queue.rb', line 16
def execute
queued_requests.each do |request|
hydra.queue(request.request)
end
hydra.run
responses = queued_requests.map { |request| request.result }
empty
responses
end
|
#queued_requests ⇒ Object
34
35
36
|
# File 'lib/chimera_http_client/queue.rb', line 34
def queued_requests
@queued_requests ||= []
end
|