Class: Delayed::Schedule::ScheduleTask

Inherits:
Struct
  • Object
show all
Defined in:
lib/delayed/schedule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



32
33
34
# File 'lib/delayed/schedule.rb', line 32

def block
  @block
end

#last_runObject

Returns the value of attribute last_run

Returns:

  • (Object)

    the current value of last_run



32
33
34
# File 'lib/delayed/schedule.rb', line 32

def last_run
  @last_run
end

#time_rangeObject

Returns the value of attribute time_range

Returns:

  • (Object)

    the current value of time_range



32
33
34
# File 'lib/delayed/schedule.rb', line 32

def time_range
  @time_range
end

Instance Method Details

#performObject



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

Returns:

  • (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