Module: RocketJob::Plugins::Job::Model::ClassMethods
- Defined in:
- lib/rocket_job/plugins/job/model.rb
Instance Method Summary collapse
-
#collective_name ⇒ Object
Returns [String] the collective name for this job class.
-
#collective_name=(collective_name) ⇒ Object
Allow the collective name for this job class to be overridden.
-
#human_name ⇒ Object
Returns [String] the human readable name for this job class.
-
#human_name=(human_name) ⇒ Object
Allow the human readable job name for this job class to be overridden.
-
#public_rocket_job_properties(*args) ⇒ Object
DEPRECATED.
-
#queued_now ⇒ Object
Scope for queued jobs that can run now I.e.
-
#rocket_job {|_self| ... } ⇒ Object
DEPRECATED.
-
#scheduled ⇒ Object
Scope for jobs scheduled to run in the future.
-
#underscore_name ⇒ Object
Returns [String] the singular name for this job class.
-
#underscore_name=(underscore_name) ⇒ Object
Allow the collective name for this job class to be overridden.
Instance Method Details
#collective_name ⇒ Object
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_name ⇒ Object
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_now ⇒ Object
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
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 |
#scheduled ⇒ Object
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_name ⇒ Object
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 |