module ProcessExecuter::Destinations

def self.compatible_with_monitored_pipe?(destination)

Returns:
  • (Boolean) - true if {MonitoredPipe} can forward data to this destination type

Parameters:
  • destination (Object) -- the destination to check
def self.compatible_with_monitored_pipe?(destination)
  matching_class = matching_destination_class(destination)
  matching_class&.compatible_with_monitored_pipe?
end

def self.factory(destination)

Raises:
  • (ProcessExecuter::ArgumentError) - if no matching destination class is found

Returns:
  • (ProcessExecuter::Destinations::DestinationBase) - an instance of the

Parameters:
  • destination (Object) -- the destination to create a handler for
def self.factory(destination)
  matching_class = matching_destination_class(destination)
  return matching_class.new(destination) if matching_class
  raise ProcessExecuter::ArgumentError, "Destination #{destination.inspect} is not compatible with MonitoredPipe"
end

def self.matching_destination_class(destination)

Returns:
  • (Class, nil) - the handler class for the given destination or `nil` if no match

Parameters:
  • destination (Object) -- the destination to check
def self.matching_destination_class(destination)
  destination_classes =
    ProcessExecuter::Destinations.constants
                                 .map { |const| ProcessExecuter::Destinations.const_get(const) }
                                 .grep(Class)
                                 .reject { |klass| klass == ProcessExecuter::Destinations::DestinationBase }
  destination_classes.find { |klass| klass.handles?(destination) }
end