SHARE
TWEET

Untitled

a guest Jul 5th, 2017 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Worker
  2.   def perform_task(job_id, action, params={}, interrupt=false)
  3.     if @pending_action && interrupt
  4.       self.task_failed
  5.     end
  6.     @job_id = job_id
  7.     self.move(params[:location] || self.position)
  8.     @pending_action = Proc.new {
  9.       self.send(action, params)
  10.     }
  11.   end
  12.  
  13.   def task_failed
  14.     # Return :failed to jobmanager for @task_id
  15.     self.clear_task
  16.   end
  17.  
  18.   # It is implied (probably in the action definitions) that this method is called when a task has been completed
  19.   def task_finished
  20.     # Return :succeeded to jobmanager for @task_id
  21.     self.clear_task
  22.   end
  23.  
  24.   def clear_task
  25.     @task_id = nil
  26.     @pending_action = nil
  27.   end
  28. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top