Class: ScraperUtils::Scheduler::ProcessRequest
- Inherits:
-
ThreadRequest
- Object
- ThreadRequest
- ScraperUtils::Scheduler::ProcessRequest
- Defined in:
- lib/scraper_utils/scheduler/process_request.rb
Overview
Encapsulates a request to be executed (usually )asynchronously by the ThreadPool)
Instance Attribute Summary collapse
-
#args ⇒ Array
readonly
The arguments to pass to the method.
-
#method_name ⇒ Symbol
readonly
The method to call on the subject.
-
#subject ⇒ Object
readonly
The object to call the method on.
Attributes inherited from ThreadRequest
Instance Method Summary collapse
-
#execute ⇒ ThreadResponse
Execute the request by calling the method on the subject If the subject has an instance variable @delay_till then that is added to the response.
-
#initialize(authority, subject, method_name, args) ⇒ ProcessRequest
constructor
Initialize a new async request.
Methods inherited from ThreadRequest
Constructor Details
#initialize(authority, subject, method_name, args) ⇒ ProcessRequest
Initialize a new async request
26 27 28 29 30 31 32 33 |
# File 'lib/scraper_utils/scheduler/process_request.rb', line 26 def initialize(, subject, method_name, args) super() @subject = subject @method_name = method_name @args = args validate! end |
Instance Attribute Details
#args ⇒ Array (readonly)
Returns The arguments to pass to the method.
16 17 18 |
# File 'lib/scraper_utils/scheduler/process_request.rb', line 16 def args @args end |
#method_name ⇒ Symbol (readonly)
Returns The method to call on the subject.
13 14 15 |
# File 'lib/scraper_utils/scheduler/process_request.rb', line 13 def method_name @method_name end |
#subject ⇒ Object (readonly)
Returns The object to call the method on.
10 11 12 |
# File 'lib/scraper_utils/scheduler/process_request.rb', line 10 def subject @subject end |
Instance Method Details
#execute ⇒ ThreadResponse
Execute the request by calling the method on the subject If the subject has an instance variable @delay_till then that is added to the response
38 39 40 41 42 43 44 |
# File 'lib/scraper_utils/scheduler/process_request.rb', line 38 def execute result = execute_block do subject.send(method_name, *args) end result.delay_till = subject.instance_variable_get(:@delay_till) result end |