Class: Delayed::Schedule::ScheduleTask
- Inherits:
-
Struct
- Object
- Struct
- Delayed::Schedule::ScheduleTask
- Defined in:
- lib/delayed/schedule.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#last_run ⇒ Object
Returns the value of attribute last_run.
-
#time_range ⇒ Object
Returns the value of attribute time_range.
Instance Method Summary collapse
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block
32 33 34 |
# File 'lib/delayed/schedule.rb', line 32 def block @block end |
#last_run ⇒ Object
Returns the value of attribute last_run
32 33 34 |
# File 'lib/delayed/schedule.rb', line 32 def last_run @last_run end |
#time_range ⇒ Object
Returns the value of attribute time_range
32 33 34 |
# File 'lib/delayed/schedule.rb', line 32 def time_range @time_range end |
Instance Method Details
#perform ⇒ Object
38 39 40 41 |
# File 'lib/delayed/schedule.rb', line 38 def perform self.last_run = Time.now.in_time_zone block.call end |
#run_necessary? ⇒ Boolean
33 34 35 36 |
# File 'lib/delayed/schedule.rb', line 33 def run_necessary? self.last_run ||= Time.now.in_time_zone last_run.nil? || (last_run + time_range) < Time.now.in_time_zone end |