uh-wm/lib/uh/wm/workers/base.rb
Thibault Jouan cd06f99e9f Fix initial events handling for mux worker
* 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.
2015-04-24 19:53:08 +00:00

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