Class: Procrastinator::Scheduler::ThreadedWorking::MultiIO

Inherits:
Object
  • Object
show all
Defined in:
lib/procrastinator/scheduler.rb

Overview

IO Multiplexer that forwards calls to a list of IO streams.

Instance Method Summary collapse

Constructor Details

#initialize(*stream) ⇒ MultiIO

Returns a new instance of MultiIO.



231
232
233
# File 'lib/procrastinator/scheduler.rb', line 231

def initialize(*stream)
   @streams = stream
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



235
236
237
238
239
# File 'lib/procrastinator/scheduler.rb', line 235

def method_missing(method_name, *args)
   able_streams(method_name).collect do |stream|
      stream.send(method_name, *args)
   end.last # forces consistent return result type for callers (but may lose some info)
end

Instance Method Details

#respond_to_missing?(method_name, include_private) ⇒ Boolean

Returns:

  • (Boolean)


241
242
243
# File 'lib/procrastinator/scheduler.rb', line 241

def respond_to_missing?(method_name, include_private)
   @streams.any? { |stream| stream.respond_to?(method_name, include_private) }
end