From 65a3159f1a1844bbc9a786b6bdefed2384b8f449 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Sat, 18 Apr 2015 03:13:13 +0000 Subject: [PATCH] Extract workers callback names in a constant --- lib/uh/wm/workers/base.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/uh/wm/workers/base.rb b/lib/uh/wm/workers/base.rb index 6f1d5f3..71f1c20 100644 --- a/lib/uh/wm/workers/base.rb +++ b/lib/uh/wm/workers/base.rb @@ -2,6 +2,8 @@ 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 @@ -10,7 +12,7 @@ module Uh @ios << io end - %w[before_wait on_timeout on_read on_read_next].each do |m| + CALLBACKS.each do |m| class_eval <<-eoh def #{m} &block if block_given? then @#{m} = block else @#{m} end