Class: Resqutils::StaleWorkers::WorkerWithStartTime
- Inherits:
-
Object
- Object
- Resqutils::StaleWorkers::WorkerWithStartTime
- Defined in:
- lib/resqutils/stale_workers.rb
Instance Attribute Summary collapse
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Instance Method Summary collapse
-
#initialize(worker, seconds_to_be_considered_stale) ⇒ WorkerWithStartTime
constructor
A new instance of WorkerWithStartTime.
- #stale? ⇒ Boolean
Constructor Details
#initialize(worker, seconds_to_be_considered_stale) ⇒ WorkerWithStartTime
Returns a new instance of WorkerWithStartTime.
47 48 49 50 51 |
# File 'lib/resqutils/stale_workers.rb', line 47 def initialize(worker,seconds_to_be_considered_stale) @worker = worker @seconds_to_be_considered_stale = seconds_to_be_considered_stale @start_time = Time.parse(worker.job["run_at"]) rescue nil end |
Instance Attribute Details
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
46 47 48 |
# File 'lib/resqutils/stale_workers.rb', line 46 def worker @worker end |
Instance Method Details
#stale? ⇒ Boolean
53 54 55 56 |
# File 'lib/resqutils/stale_workers.rb', line 53 def stale? return false if @start_time.nil? @start_time <= (Time.now - @seconds_to_be_considered_stale) end |