Class: Taskinator::Task::Step

Inherits:
Taskinator::Task show all
Defined in:
lib/taskinator/task.rb

Overview

a task which invokes the specified method on the definition the args must be intrinsic types, since they are serialized to JSON

Instance Attribute Summary collapse

Attributes inherited from Taskinator::Task

#next, #options, #process, #uuid

Instance Method Summary collapse

Methods inherited from Taskinator::Task

#<=>, base_key, #cancelled?, define_step_task, define_sub_process_task, #enqueue, #on_completed_entry, #paused?, #to_s

Methods included from Persistence

included

Constructor Details

#initialize(process, method, args, options = {}) ⇒ Step

Returns a new instance of Step.

Raises:

  • (ArgumentError)


115
116
117
118
119
120
121
122
123
124
# File 'lib/taskinator/task.rb', line 115

def initialize(process, method, args, options={})
  super(process, options)
  @definition = process.definition  # for convenience

  raise ArgumentError, 'method' if method.nil?
  raise NoMethodError, method unless executor.respond_to?(method)

  @method = method
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



113
114
115
# File 'lib/taskinator/task.rb', line 113

def args
  @args
end

#definitionObject (readonly)

Returns the value of attribute definition.



111
112
113
# File 'lib/taskinator/task.rb', line 111

def definition
  @definition
end

#methodObject (readonly)

Returns the value of attribute method.



112
113
114
# File 'lib/taskinator/task.rb', line 112

def method
  @method
end

Instance Method Details

#accept(visitor) ⇒ Object



141
142
143
144
145
146
# File 'lib/taskinator/task.rb', line 141

def accept(visitor)
  super
  visitor.visit_type(:definition)
  visitor.visit_attribute(:method)
  visitor.visit_args(:args)
end

#can_complete_task?Boolean

NOTE: this _does not_ work when checking out-of-process

Returns:

  • (Boolean)


137
138
139
# File 'lib/taskinator/task.rb', line 137

def can_complete_task?
  defined?(@is_complete) && @is_complete
end

#executorObject



126
127
128
# File 'lib/taskinator/task.rb', line 126

def executor
  @executor ||= Taskinator::Executor.new(@definition)
end

#startObject



130
131
132
133
134
# File 'lib/taskinator/task.rb', line 130

def start
  # ASSUMPTION: when the method returns, the task is considered to be complete
  executor.send(method, *args)
  @is_complete = true
end