class ProcessExecuter::Options::SpawnWithTimeoutOptions

Defines options for {ProcessExecuter.spawn_with_timeout}

@api public

Private Instance Methods

define_options() click to toggle source

The options allowed for objects of this class @return [Array<OptionDefinition>] @api private

# File lib/process_executer/options/spawn_with_timeout_options.rb, line 18
def define_options
  [
    *super,
    OptionDefinition.new(:timeout_after, default: nil, validator: method(:validate_timeout_after))
  ].freeze
end
validate_timeout_after(_key, _value) click to toggle source

Note an error if timeout_after is not nil or a non-negative real number

@param _key [Symbol] the option key (not used)

@param _value [Object] the option value (not used)

@return [void]

@api private

# File lib/process_executer/options/spawn_with_timeout_options.rb, line 35
def validate_timeout_after(_key, _value)
  return if timeout_after.nil?
  return if timeout_after.is_a?(Numeric) && timeout_after.real? && !timeout_after.negative?

  errors << "timeout_after must be nil or a non-negative real number but was #{timeout_after.inspect}"
end