Refactor Workers::Base callback definitions

This commit is contained in:
Thibault Jouan 2015-04-18 03:09:16 +00:00
parent 41b99957fb
commit 4015a301cc

View File

@ -10,20 +10,12 @@ module Uh
@ios << io @ios << io
end end
def before_wait &block %w[before_wait on_timeout on_read on_read_next].each do |m|
if block_given? then @before_wait = block else @before_wait end class_eval <<-eoh
end def #{m} &block
if block_given? then @#{m} = block else @#{m} end
def on_timeout &block end
if block_given? then @on_timeout = block else @on_timeout end eoh
end
def on_read &block
if block_given? then @on_read = block else @on_read end
end
def on_read_next &block
if block_given? then @on_read_next = block else @on_read_next end
end end
end end
end end