module BatchKit::ActsAsJob

When included into a class, marks the class as a BatchKit job. The including class has the following class methods added, which act as a DSL for specifying the job properties and behaviour:

Instances of the including class also get the following instance methods:

Public Class Methods

included(base) click to toggle source

Hook used to extend the including class with class methods defined in the ActsAsJob::ClassMethods module.

Creates a Job::Definition object to hold details of the job, and stores it away in a @__job__ class instance variable.

# File lib/batch-kit/framework/acts_as_job.rb, line 173
def self.included(base)
    base.extend(ClassMethods)
    caller.find{ |f| !(f =~ /batch-kit.framework/) } =~ /^((?:[a-zA-Z]:)?[^:]+)/
    job_file = File.realpath($1)
    job_defn = Job::Definition.new(base, job_file)
    base.instance_variable_set :@__job__, job_defn
    Events.publish(base, 'acts_as_job.included', job_defn)
end

Public Instance Methods

job() click to toggle source

@return [Job::Definition] The JobDefinition for this job instance.

# File lib/batch-kit/framework/acts_as_job.rb, line 184
def job
    self.class.job_definition
end
job_run() click to toggle source

@return [Job::Run] The JobRun for this job instance.

# File lib/batch-kit/framework/acts_as_job.rb, line 190
def job_run
    @__job_run__
end