Class: Steve::Job
- Inherits:
-
Object
- Object
- Steve::Job
- Defined in:
- lib/steve/job.rb
Defined Under Namespace
Classes: Delay, Error, FakeQueuedJob
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.queue(params = {}, &block) ⇒ Object
Queue the job.
-
.run(params = {}) ⇒ Object
Live run a job after passing the params.
Instance Method Summary collapse
-
#initialize(job, params = {}) ⇒ Job
constructor
A new instance of Job.
Constructor Details
#initialize(job, params = {}) ⇒ Job
Returns a new instance of Job.
13 14 15 16 |
# File 'lib/steve/job.rb', line 13 def initialize(job, params = {}) @job = job @params = job.params end |
Instance Attribute Details
#job ⇒ Object (readonly)
Returns the value of attribute job.
10 11 12 |
# File 'lib/steve/job.rb', line 10 def job @job end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/steve/job.rb', line 11 def params @params end |
Class Method Details
.queue(params = {}, &block) ⇒ Object
Queue the job
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/steve/job.rb', line 19 def self.queue(params = {}, &block) if Steve.run_jobs_in_foreground Rails.logger.info "\e[33m -> Started to exectute #{self.to_s} job in foreground\e[0m" run(params) Rails.logger.info "\e[33m -> Finished executing #{self.to_s} job in foreground\e[0m" else Rails.logger.info "\e[33m -> Queued #{self.to_s} job\e[0m" QueuedJob.queue(self, params, &block) end end |
.run(params = {}) ⇒ Object
Live run a job after passing the params
31 32 33 |
# File 'lib/steve/job.rb', line 31 def self.run(params = {}) self.new(FakeQueuedJob.new(params)).perform end |