Class: Boechat::Core::Service::RequestList
- Inherits:
-
Object
- Object
- Boechat::Core::Service::RequestList
- Defined in:
- lib/boechat/core/service/request_list.rb
Overview
Class to save all user request objects to execute them one at a time or all in parallel
Instance Attribute Summary collapse
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, requester) ⇒ Object
- #call(request_identifier = nil) ⇒ Object
-
#initialize(requests = {}) ⇒ RequestList
constructor
A new instance of RequestList.
Constructor Details
#initialize(requests = {}) ⇒ RequestList
Returns a new instance of RequestList.
10 11 12 |
# File 'lib/boechat/core/service/request_list.rb', line 10 def initialize(requests = {}) @requests = requests end |
Instance Attribute Details
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
8 9 10 |
# File 'lib/boechat/core/service/request_list.rb', line 8 def requests @requests end |
Instance Method Details
#[](key) ⇒ Object
30 31 32 |
# File 'lib/boechat/core/service/request_list.rb', line 30 def [](key) requests[key] end |
#[]=(key, requester) ⇒ Object
26 27 28 |
# File 'lib/boechat/core/service/request_list.rb', line 26 def []=(key, requester) requests[key] = requester end |
#call(request_identifier = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/boechat/core/service/request_list.rb', line 14 def call(request_identifier = nil) if request_identifier.nil? hydra = Typhoeus::Hydra.hydra requests.each_pair { |_key, request| hydra.queue(request.call) } hydra.run elsif requests.key?(request_identifier) requests[request_identifier].call end self end |