lib/pigeon/task.rb in pigeon-0.4.4 vs lib/pigeon/task.rb in pigeon-0.4.6
- old
+ new
@@ -36,17 +36,19 @@
@created_at = Time.now
after_initialized
end
- # Kicks off the task. An optional callback is executed just before each
+ # Kicks off the task. The processor execurting the task should be supplied
+ # as the first argument. An optional callback is executed just before each
# state is excuted and is passed the state name as a symbol.
- def run!(initial_state = nil, &callback)
+ def run!(processor = nil, initial_state = nil, &callback)
@callback = callback if (block_given?)
@state = initial_state || self.class.initial_state
@started_at = Time.now
+ @processor = processor
run_state!(@state)
end
# Returns true if the task is in the finished state, false otherwise.
def finished?