Module: ConcurrentEnumerable::EnumerableInterface

Included in:
Parallel
Defined in:
lib/concurrent_enumerable/enumerable_interface.rb

Class Method Summary collapse

Class Method Details

.use(runner, methods) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/concurrent_enumerable/enumerable_interface.rb', line 5

def use(runner, methods)
  enumerable_methods = Enumerable.instance_methods.map(&:to_s)
  enumerable_methods << 'each'
  methods.each do |method|
    next unless enumerable_methods.include?(method)
    class_eval <<-RUBY
    def #{method}(*args, &block)
      #{runner}(:#{method}, *args, &block)
    end
    RUBY
  end
end