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?, #queue, #to_s
Methods included from Persistence
add_process_to_list, included, list_key
Constructor Details
#initialize(process, job, args, options = {}) ⇒ Job
Returns a new instance of Job.
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/taskinator/task.rb', line 177 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.
175 176 177 |
# File 'lib/taskinator/task.rb', line 175 def args @args end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
173 174 175 |
# File 'lib/taskinator/task.rb', line 173 def definition @definition end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
174 175 176 |
# File 'lib/taskinator/task.rb', line 174 def job @job end |
Instance Method Details
#accept(visitor) ⇒ Object
202 203 204 205 206 207 |
# File 'lib/taskinator/task.rb', line 202 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
198 199 200 |
# File 'lib/taskinator/task.rb', line 198 def can_complete_task? defined?(@is_complete) && @is_complete end |
#enqueue ⇒ Object
188 189 190 |
# File 'lib/taskinator/task.rb', line 188 def enqueue Taskinator.queue.enqueue_job(self) end |
#perform {|job, args| ... } ⇒ Object
192 193 194 195 |
# File 'lib/taskinator/task.rb', line 192 def perform(&block) yield(job, args) @is_complete = true end |