Module: Delayed::Backend::Base
- Included in:
- ActiveRecord::Job, DataMapper::Job, MongoMapper::Job
- Defined in:
- lib/delayed/backend/base.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- ParseObjectFromYaml =
/\!ruby\/\w+\:([^\s]+)/
Class Method Summary collapse
Instance Method Summary collapse
- #failed? ⇒ Boolean (also: #failed)
-
#invoke_job ⇒ Object
Moved into its own method so that new_relic can trace it.
- #max_attempts ⇒ Object
- #name ⇒ Object
- #payload_object ⇒ Object
- #payload_object=(object) ⇒ Object
- #reschedule_at ⇒ Object
-
#unlock ⇒ Object
Unlock this job (note: not saved to DB).
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/delayed/backend/base.rb', line 7 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#failed? ⇒ Boolean Also known as: failed
48 49 50 |
# File 'lib/delayed/backend/base.rb', line 48 def failed? failed_at end |
#invoke_job ⇒ Object
Moved into its own method so that new_relic can trace it.
73 74 75 |
# File 'lib/delayed/backend/base.rb', line 73 def invoke_job payload_object.perform end |
#max_attempts ⇒ Object
89 90 91 |
# File 'lib/delayed/backend/base.rb', line 89 def max_attempts payload_object.max_attempts if payload_object.respond_to?(:max_attempts) end |
#name ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/delayed/backend/base.rb', line 53 def name @name ||= begin payload = payload_object if payload.respond_to?(:display_name) payload.display_name else payload.class.name end end end |
#payload_object ⇒ Object
68 69 70 |
# File 'lib/delayed/backend/base.rb', line 68 def payload_object @payload_object ||= deserialize(self['handler']) end |
#payload_object=(object) ⇒ Object
64 65 66 |
# File 'lib/delayed/backend/base.rb', line 64 def payload_object=(object) self['handler'] = object.to_yaml end |
#reschedule_at ⇒ Object
83 84 85 86 87 |
# File 'lib/delayed/backend/base.rb', line 83 def reschedule_at payload_object.respond_to?(:reschedule_at) ? payload_object.reschedule_at(self.class.db_time_now, attempts) : self.class.db_time_now + (attempts ** 4) + 5 end |
#unlock ⇒ Object
Unlock this job (note: not saved to DB)
78 79 80 81 |
# File 'lib/delayed/backend/base.rb', line 78 def unlock self.locked_at = nil self.locked_by = nil end |