Class: ActiveJob::Scheduler::Task

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/active_job/scheduler/task.rb

Overview

Run the scheduler as a Rake task, and preload the Rails environment.

Example Task:

ActiveJob::Scheduler::Task.new :schedule

Example Shell Command:

rake schedule

The task can also be pre-loaded with a task called ‘schedule:setup`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(with_name = :schedule) {|_self| ... } ⇒ Task

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:



19
20
21
22
23
# File 'lib/active_job/scheduler/task.rb', line 19

def initialize(with_name=:schedule)
  @name = with_name
  yield self if block_given?
  define
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/active_job/scheduler/task.rb', line 17

def name
  @name
end

Instance Method Details

#defineObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/active_job/scheduler/task.rb', line 25

def define
  namespace name do
    task :setup

    task :run do
      ActiveJob::Scheduler::Cli.run ARGV, ENV
    end
  end

  desc "Run the ActiveJob::Scheduler"
  task name => ["#{name}:setup", "#{name}:run"]
end