Class: Actn::Jobs::Base
- Inherits:
-
Object
- Object
- Actn::Jobs::Base
- Defined in:
- lib/actn/jobs/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#job ⇒ Object
Returns the value of attribute job.
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(job) ⇒ Base
constructor
A new instance of Base.
- #perform ⇒ Object
- #test_and_perform ⇒ Object
Constructor Details
#initialize(job) ⇒ Base
Returns a new instance of Base.
11 12 13 14 |
# File 'lib/actn/jobs/base.rb', line 11 def initialize job @job = job @record = job.record || Oj.load(DB::Set[job.table_name].find_by({uuid: job.record_uuid})) end |
Instance Attribute Details
#job ⇒ Object
Returns the value of attribute job.
9 10 11 |
# File 'lib/actn/jobs/base.rb', line 9 def job @job end |
#record ⇒ Object
Returns the value of attribute record.
9 10 11 |
# File 'lib/actn/jobs/base.rb', line 9 def record @record end |
Instance Method Details
#perform ⇒ Object
16 17 |
# File 'lib/actn/jobs/base.rb', line 16 def perform end |
#test_and_perform ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/actn/jobs/base.rb', line 19 def test_and_perform unless self.record $stderr.puts "[#{self.class.name}#test_and_perform, #{Time.now}]: Record not found" return end if job.hook['conditions'].nil? || ( !job.hook['conditions'].map{|c| eval(c,binding) ? true : false }.include?(false) ) run else Jobs.logger.warn "Conditions failed, CONDITIONS: #{job.hook['conditions']} RECORD: #{self.record}" job.update(result: {error: "Conditions failed"}) end end |