* Rename `before_wait' worker callback to `before_watch'; * Setup `before_watch' callback in the runner, handling events with the manager; * Test the mux worker with a cucumber scenario.
28 lines
545 B
Ruby
28 lines
545 B
Ruby
module Uh
|
|
module WM
|
|
module Workers
|
|
class Base
|
|
CALLBACKS = %w[before_watch on_timeout on_read on_read_next].freeze
|
|
|
|
def initialize **options
|
|
@ios = []
|
|
end
|
|
|
|
def watch io
|
|
@ios << io
|
|
end
|
|
|
|
CALLBACKS.each do |m|
|
|
define_method m do |*_, &block|
|
|
if block
|
|
instance_variable_set "@#{m}".to_sym, block
|
|
else
|
|
instance_variable_get "@#{m}".to_sym
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|