Module: RocketJob::Plugins::Job::Model::ClassMethods

Defined in:
lib/rocket_job/plugins/job/model.rb

Instance Method Summary collapse

Instance Method Details

#collective_nameObject

Returns [String] the collective name for this job class

Example:

job = DataStudyJob.new
job.collective_name
# => "data_studies"


133
134
135
# File 'lib/rocket_job/plugins/job/model.rb', line 133

def collective_name
  @collective_name ||= name.sub(/Job$/, '').pluralize.underscore
end

#collective_name=(collective_name) ⇒ Object

Allow the collective name for this job class to be overridden



138
139
140
# File 'lib/rocket_job/plugins/job/model.rb', line 138

def collective_name=(collective_name)
  @collective_name = collective_name
end

#human_nameObject

Returns [String] the human readable name for this job class

Example:

job = DataStudyJob.new
job.human_name
# => "Data Study"


118
119
120
# File 'lib/rocket_job/plugins/job/model.rb', line 118

def human_name
  @human_name ||= name.sub(/Job$/, '').titleize
end

#human_name=(human_name) ⇒ Object

Allow the human readable job name for this job class to be overridden



123
124
125
# File 'lib/rocket_job/plugins/job/model.rb', line 123

def human_name=(human_name)
  @human_name = human_name
end

#public_rocket_job_properties(*args) ⇒ Object

DEPRECATED



160
161
162
163
# File 'lib/rocket_job/plugins/job/model.rb', line 160

def public_rocket_job_properties(*args)
  warn "Replace calls to .public_rocket_job_properties by adding `user_editable: true` option to the field declaration in #{name} for: #{args.inspect}"
  self.user_editable_fields += args.collect(&:to_sym)
end

#queued_nowObject

Scope for queued jobs that can run now I.e. Queued jobs excluding scheduled jobs



149
150
151
# File 'lib/rocket_job/plugins/job/model.rb', line 149

def queued_now
  queued.or({:run_at => nil}, {:run_at.lte => Time.now})
end

#rocket_job {|_self| ... } ⇒ Object

DEPRECATED

Yields:

  • (_self)

Yield Parameters:



154
155
156
157
# File 'lib/rocket_job/plugins/job/model.rb', line 154

def rocket_job
  warn 'Replace calls to .rocket_job with calls to set class instance variables. For example: self.priority = 50'
  yield(self)
end

#scheduledObject

Scope for jobs scheduled to run in the future



143
144
145
# File 'lib/rocket_job/plugins/job/model.rb', line 143

def scheduled
  queued.where(:run_at.gt => Time.now)
end

#underscore_nameObject

Returns [String] the singular name for this job class

Example:

job = DataStudyJob.new
job.underscore_name
# => "data_study"


103
104
105
# File 'lib/rocket_job/plugins/job/model.rb', line 103

def underscore_name
  @underscore_name ||= name.sub(/Job$/, '').underscore
end

#underscore_name=(underscore_name) ⇒ Object

Allow the collective name for this job class to be overridden



108
109
110
# File 'lib/rocket_job/plugins/job/model.rb', line 108

def underscore_name=(underscore_name)
  @underscore_name = underscore_name
end