Class: Jobs::Base
Overview
Base class for all delayed jobs
Direct Known Subclasses
Analysis::Base, CreateDataset, DestroyDataset, ExpireDownloads
Instance Method Summary (collapse)
-
- (Boolean) ==(other)
(also: #eql?)
Compare objects for equality based on their attributes.
-
- (Hash) attributes
Get a hash of attributes from the state variables.
-
- (undefined) error(job, exception)
private
Report any exceptions to Airbrake, if it's enabled.
-
- (undefined) initialize(args = { })
constructor
Initialize the job from a hash of attributes in a generic way.
-
- (Integer) max_attempts
private
Don't restart jobs on error.
Constructor Details
- (undefined) initialize(args = { })
Initialize the job from a hash of attributes in a generic way
This constructor will simply set all of the passed args as attribute values, if the job has the given attribute.
37 38 39 40 41 42 43 |
# File 'lib/jobs/base.rb', line 37 def initialize(args = { }) @state_vars = args.keys args.each_pair do |key, value| self.send("#{key}=", value) if self.respond_to?("#{key}=") end end |
Instance Method Details
- (Boolean) ==(other) Also known as: eql?
Compare objects for equality based on their attributes
69 70 71 |
# File 'lib/jobs/base.rb', line 69 def ==(other) attributes == other.attributes end |
- (Hash) attributes
Get a hash of attributes from the state variables
59 60 61 62 63 |
# File 'lib/jobs/base.rb', line 59 def attributes ret = {} @state_vars.each { |k| ret[k] = instance_variable_get("@#{k.to_s}") } ret end |
- (undefined) error(job, exception)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Report any exceptions to Airbrake, if it's enabled
This method is a callback that is invoked by Delayed::Job. No tests, as it's merely a wrapper on the Airbrake gem.
:nocov:
84 85 86 87 88 |
# File 'lib/jobs/base.rb', line 84 def error(job, exception) unless Settings.airbrake_key.blank? Airbrake.notify(exception) end end |
- (Integer) max_attempts
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Don't restart jobs on error
Restarting isn't going to help resolve any errors that are presented, so don't try it.
:nocov:
99 100 101 |
# File 'lib/jobs/base.rb', line 99 def max_attempts 1 end |