#
Job Callbacks
The Jobly::Job
class supports these callback methods:
Each callback method can either be a block or a symbol that points to a local method. When using a block, you will have the params
variable available, with all the parameters sent to the job.
jobs/greet.rb
class Greet < Jobly::Job
before do
logger.info "Starting with #{params[:message]}"
end
after :reboot_computer
def execute(message: "Hello")
puts message
end
def reboot_computer
system "reboot"
end
end
In order to conditionally skip a job from its before
block, you can call skip_job
. This will avoid running the job, and will execute the on_skip
action and the after
action, if present.