Class: Scheduler::Schedulable::Delayed

Inherits:
Object
  • Object
show all
Defined in:
lib/scheduler/schedulable.rb

Overview

A class to delay jobs.

Instance Method Summary collapse

Constructor Details

#initialize(job_class, time) ⇒ Delayed

New delayed job.



18
19
20
21
# File 'lib/scheduler/schedulable.rb', line 18

def initialize(job_class, time)
  @job_class = job_class
  @time = time
end

Instance Method Details

#schedule(executable_class, *job_args) ⇒ Object

Creates an instance of this class and schedules the job.

Parameters:

  • executable_class (String)

    the class of the job to run.

  • *job_args (Array)

    job arguments

Returns:

  • (Object)

    the created job.



30
31
32
# File 'lib/scheduler/schedulable.rb', line 30

def schedule(executable_class, *job_args)
  @job_class.create(executable_class: executable_class, args: job_args, run_at: Time.now + @time).schedule
end