Class: Qu::Payload
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Qu::Payload
show all
- Includes:
- Logger
- Defined in:
- lib/qu/payload.rb
Instance Method Summary
collapse
Methods included from Logger
#clean_backtrace, #log_exception, #logger
Constructor Details
#initialize(options = {}) ⇒ Payload
Returns a new instance of Payload.
9
10
11
12
|
# File 'lib/qu/payload.rb', line 9
def initialize(options = {})
super
self.args ||= []
end
|
Instance Method Details
#klass ⇒ Object
14
15
16
|
# File 'lib/qu/payload.rb', line 14
def klass
constantize(super)
end
|
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/qu/payload.rb', line 22
def perform
klass.perform(*args)
Qu.backend.completed(self)
rescue Qu::Worker::Abort
logger.debug "Releasing job #{self}"
Qu.backend.release(self)
raise
rescue Exception => e
logger.fatal "Job #{self} failed"
log_exception(e)
Qu.failure.create(self, e) if Qu.failure
Qu.backend.failed(self, e)
end
|
#queue ⇒ Object
18
19
20
|
# File 'lib/qu/payload.rb', line 18
def queue
(klass.instance_variable_get(:@queue) || 'default').to_s
end
|
#to_s ⇒ Object
36
37
38
|
# File 'lib/qu/payload.rb', line 36
def to_s
"#{id}:#{klass}:#{args.inspect}"
end
|