@@ -15,13 +15,13 @@ def define_job_task(process, job, args, options={})
1515 Job . new ( process , job , args , options )
1616 end
1717
18- def define_hook_task ( process , method , args , options = { } )
19- Hook . new ( process , method , args , options )
20- end
21-
2218 def define_sub_process_task ( process , sub_process , options = { } )
2319 SubProcess . new ( process , sub_process , options )
2420 end
21+
22+ def define_hook_task ( process , method , args , options = { } )
23+ Hook . new ( process , method , args , options )
24+ end
2525 end
2626
2727 attr_reader :process
@@ -214,65 +214,6 @@ def inspect
214214
215215 #--------------------------------------------------
216216
217- # a task which invokes the specified method on the definition
218- # the task is executed independently of the process, so there isn't any further
219- # processing once it completes (or fails)
220- # the args must be intrinsic types, since they are serialized to YAML
221- class Hook < Task
222- attr_reader :method
223- attr_reader :args
224-
225- def initialize ( process , method , args , options = { } )
226- super ( process , options )
227-
228- raise ArgumentError , 'method' if method . nil?
229- raise NoMethodError , method unless executor . respond_to? ( method )
230-
231- @method = method
232- @args = args
233- end
234-
235- def enqueue
236- Taskinator . queue . enqueue_task ( self )
237- end
238-
239- def start
240- executor . send ( method , *args )
241- # ASSUMPTION: when the method returns, the task is considered to be complete
242- complete!
243-
244- rescue => e
245- Taskinator . logger . error ( e )
246- Taskinator . logger . debug ( e . backtrace )
247- fail! ( e )
248- raise e
249- end
250-
251- def accept ( visitor )
252- super
253- visitor . visit_attribute ( :method )
254- visitor . visit_args ( :args )
255- end
256-
257- def executor
258- @executor ||= Taskinator ::Executor . new ( definition , self )
259- end
260-
261- def incr_count?
262- false
263- end
264-
265- def notify_process?
266- false
267- end
268-
269- def inspect
270- %(#<#{ self . class . name } :0x#{ self . __id__ . to_s ( 16 ) } uuid="#{ uuid } ", definition=:#{ definition } , method=:#{ method } , args=#{ args } , current_state=:#{ current_state } >)
271- end
272- end
273-
274- #--------------------------------------------------
275-
276217 # a task which invokes the specified background job
277218 # the args must be intrinsic types, since they are serialized to YAML
278219 class Job < Task
@@ -370,5 +311,64 @@ def inspect
370311 %(#<#{ self . class . name } :0x#{ self . __id__ . to_s ( 16 ) } uuid="#{ uuid } ", definition=:#{ definition } , sub_process=#{ sub_process . inspect } , current_state=:#{ current_state } >)
371312 end
372313 end
314+
315+ #--------------------------------------------------
316+
317+ # a task which invokes the specified method on the definition
318+ # the task is executed independently of the process, so there isn't any further
319+ # processing once it completes (or fails)
320+ # the args must be intrinsic types, since they are serialized to YAML
321+ class Hook < Task
322+ attr_reader :method
323+ attr_reader :args
324+
325+ def initialize ( process , method , args , options = { } )
326+ super ( process , options )
327+
328+ raise ArgumentError , 'method' if method . nil?
329+ raise NoMethodError , method unless executor . respond_to? ( method )
330+
331+ @method = method
332+ @args = args
333+ end
334+
335+ def enqueue
336+ Taskinator . queue . enqueue_task ( self )
337+ end
338+
339+ def start
340+ executor . send ( method , *args )
341+ # ASSUMPTION: when the method returns, the task is considered to be complete
342+ complete!
343+
344+ rescue => e
345+ Taskinator . logger . error ( e )
346+ Taskinator . logger . debug ( e . backtrace )
347+ fail! ( e )
348+ raise e
349+ end
350+
351+ def accept ( visitor )
352+ super
353+ visitor . visit_attribute ( :method )
354+ visitor . visit_args ( :args )
355+ end
356+
357+ def executor
358+ @executor ||= Taskinator ::Executor . new ( definition , self )
359+ end
360+
361+ def incr_count?
362+ false
363+ end
364+
365+ def notify_process?
366+ false
367+ end
368+
369+ def inspect
370+ %(#<#{ self . class . name } :0x#{ self . __id__ . to_s ( 16 ) } uuid="#{ uuid } ", definition=:#{ definition } , method=:#{ method } , args=#{ args } , current_state=:#{ current_state } >)
371+ end
372+ end
373373 end
374374end
0 commit comments