Skip to content

Commit 96c9fbb

Browse files
committed
Go back to explicit method definitions for lifecycle hooks
I think the metaprogramming version was not better.
1 parent 378107c commit 96c9fbb

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

lib/solid_queue.rb

+22-8
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,28 @@ module SolidQueue
4343

4444
delegate :on_start, :on_stop, to: Supervisor
4545

46-
# on_worker_start, on_worker_stop, on_dispatcher_start ...
47-
%w[ worker dispatcher scheduler ].each do |process|
48-
%w[ start stop ].each do |action|
49-
define_method("on_#{process}_#{action}") do |&block|
50-
# Worker.on_start(&block), Dispatcher.on_stop(&block)
51-
const_get(process.capitalize).public_send("on_#{action}", &block)
52-
end
53-
end
46+
def on_worker_start(...)
47+
Worker.on_start(...)
48+
end
49+
50+
def on_worker_stop(...)
51+
Worker.on_stop(...)
52+
end
53+
54+
def on_dispatcher_start(...)
55+
Dispatcher.on_start(...)
56+
end
57+
58+
def on_dispatcher_stop(...)
59+
Dispatcher.on_stop(...)
60+
end
61+
62+
def on_scheduler_start(...)
63+
Scheduler.on_start(...)
64+
end
65+
66+
def on_scheduler_stop(...)
67+
Scheduler.on_stop(...)
5468
end
5569

5670
def supervisor?

0 commit comments

Comments
 (0)