Class: PgQueue::Job
- Inherits:
-
Object
- Object
- PgQueue::Job
- Defined in:
- lib/pg_queue/job.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Job
constructor
A new instance of Job.
- #perform ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Job
Returns a new instance of Job.
7 8 9 10 11 |
# File 'lib/pg_queue/job.rb', line 7 def initialize(attributes) @id = attributes["id"] @klass = Object.const_get(attributes["class_name"]) @args = MultiJson.decode(attributes["args"]) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/pg_queue/job.rb', line 5 def args @args end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/pg_queue/job.rb', line 5 def id @id end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/pg_queue/job.rb', line 5 def klass @klass end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/pg_queue/job.rb', line 13 def perform PgQueue.logger.debug("performing job #{@id}") klass.perform(*args) PgQueue.logger.debug("job #{@id} performed") klass.after_perform(*args) if klass.respond_to?(:after_perform) end |