Extract workers callback names in a constant
This commit is contained in:
		@@ -2,6 +2,8 @@ module Uh
 | 
				
			|||||||
  module WM
 | 
					  module WM
 | 
				
			||||||
    module Workers
 | 
					    module Workers
 | 
				
			||||||
      class Base
 | 
					      class Base
 | 
				
			||||||
 | 
					        CALLBACKS = %w[before_wait on_timeout on_read on_read_next].freeze
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def initialize **options
 | 
					        def initialize **options
 | 
				
			||||||
          @ios = []
 | 
					          @ios = []
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
@@ -10,7 +12,7 @@ module Uh
 | 
				
			|||||||
          @ios << io
 | 
					          @ios << io
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        %w[before_wait on_timeout on_read on_read_next].each do |m|
 | 
					        CALLBACKS.each do |m|
 | 
				
			||||||
          class_eval <<-eoh
 | 
					          class_eval <<-eoh
 | 
				
			||||||
            def #{m} &block
 | 
					            def #{m} &block
 | 
				
			||||||
              if block_given? then @#{m} = block else @#{m} end
 | 
					              if block_given? then @#{m} = block else @#{m} end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user