Class: Taskinator::Task::Job
- Inherits:
-
Taskinator::Task
- Object
- Taskinator::Task
- Taskinator::Task::Job
- Defined in:
- lib/taskinator/task.rb
Overview
a task which invokes the specified background job the args must be intrinsic types, since they are serialized to YAML
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
Attributes inherited from Taskinator::Task
#next, #options, #process, #uuid
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
-
#can_complete_task? ⇒ Boolean
NOTE: this _does not_ work when checking out-of-process.
- #enqueue ⇒ Object
-
#initialize(process, job, args, options = {}) ⇒ Job
constructor
A new instance of Job.
- #perform {|job, args| ... } ⇒ Object
Methods inherited from Taskinator::Task
#<=>, base_key, #cancelled?, define_job_task, define_step_task, define_sub_process_task, #on_completed_entry, #on_failed_entry, #paused?, #to_s
Methods included from Persistence
Constructor Details
#initialize(process, job, args, options = {}) ⇒ Job
Returns a new instance of Job.
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/taskinator/task.rb', line 173 def initialize(process, job, args, ={}) super(process, ) @definition = process.definition # for convenience raise ArgumentError, 'job' if job.nil? raise ArgumentError, 'job' unless job.methods.include?(:perform) || job.instance_methods.include?(:perform) @job = job @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
171 172 173 |
# File 'lib/taskinator/task.rb', line 171 def args @args end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
169 170 171 |
# File 'lib/taskinator/task.rb', line 169 def definition @definition end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
170 171 172 |
# File 'lib/taskinator/task.rb', line 170 def job @job end |
Instance Method Details
#accept(visitor) ⇒ Object
198 199 200 201 202 203 |
# File 'lib/taskinator/task.rb', line 198 def accept(visitor) super visitor.visit_type(:definition) visitor.visit_type(:job) visitor.visit_args(:args) end |
#can_complete_task? ⇒ Boolean
NOTE: this _does not_ work when checking out-of-process
194 195 196 |
# File 'lib/taskinator/task.rb', line 194 def can_complete_task? defined?(@is_complete) && @is_complete end |
#enqueue ⇒ Object
184 185 186 |
# File 'lib/taskinator/task.rb', line 184 def enqueue Taskinator.queue.enqueue_job(self) end |
#perform {|job, args| ... } ⇒ Object
188 189 190 191 |
# File 'lib/taskinator/task.rb', line 188 def perform(&block) yield(job, args) @is_complete = true end |