Module: HttpClientGenerator::TimeoutNormalizer

Defined in:
lib/http_client_generator/timeout_normalizer.rb

Overview

:nodoc:

Constant Summary collapse

VALID_KEYS =
%i[connect read write].freeze
ERROR_MESSAGE =
'Use timeout(global), timeout(:null), or timeout(connect: x, read: y, write: z).'

Class Method Summary collapse

Class Method Details

.call(value = nil, **options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/http_client_generator/timeout_normalizer.rb', line 9

def self.call(value = nil, **options)
  timeout_value = build_timeout_value(value, options)
  case timeout_value
  when Numeric, :null
    timeout_value
  when Hash
    normalize_hash(timeout_value)
  else
    raise ArgumentError, ERROR_MESSAGE
  end
end