uh-wm/lib/uh/wm/workers/base.rb
2015-04-18 14:40:12 +00:00

28 lines
544 B
Ruby

module Uh
module WM
module Workers
class Base
CALLBACKS = %w[before_wait 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