class HTTPX::Timeout

  1. lib/httpx/timeout.rb
Superclass: Object

Methods

Public Class

  1. new
  2. new

Public Instance

  1. ==
  2. connect_timeout
  3. merge
  4. operation_timeout
  5. total_timeout

Constants

CONNECT_TIMEOUT = 60  
OPERATION_TIMEOUT = 60  

Public Class methods

new (opts = {})
[show source]
   # File lib/httpx/timeout.rb
10 def self.new(opts = {})
11   return opts if opts.is_a?(Timeout)
12 
13   super(**opts)
14 end
new (connect_timeout: CONNECT_TIMEOUT, operation_timeout: OPERATION_TIMEOUT, total_timeout: nil, loop_timeout: nil)
[show source]
   # File lib/httpx/timeout.rb
18 def initialize(connect_timeout: CONNECT_TIMEOUT,
19                operation_timeout: OPERATION_TIMEOUT,
20                total_timeout: nil,
21                loop_timeout: nil)
22   @connect_timeout = connect_timeout
23   @operation_timeout = operation_timeout
24   @total_timeout = total_timeout
25 
26   return unless loop_timeout
27 
28   # :nocov:
29   warn ":loop_timeout is deprecated, use :operation_timeout instead"
30   @operation_timeout = loop_timeout
31   # :nocov:
32 end

Public Instance methods

== (other)
[show source]
   # File lib/httpx/timeout.rb
34 def ==(other)
35   if other.is_a?(Timeout)
36     @connect_timeout == other.instance_variable_get(:@connect_timeout) &&
37       @operation_timeout == other.instance_variable_get(:@operation_timeout) &&
38       @total_timeout == other.instance_variable_get(:@total_timeout)
39   else
40     super
41   end
42 end
merge (other)
[show source]
   # File lib/httpx/timeout.rb
44 def merge(other)
45   case other
46   when Hash
47     timeout = Timeout.new(other)
48     merge(timeout)
49   when Timeout
50     connect_timeout = other.instance_variable_get(:@connect_timeout) || @connect_timeout
51     operation_timeout = other.instance_variable_get(:@operation_timeout) || @operation_timeout
52     total_timeout = other.instance_variable_get(:@total_timeout) || @total_timeout
53     Timeout.new(connect_timeout: connect_timeout,
54                 operation_timeout: operation_timeout,
55                 total_timeout: total_timeout)
56   else
57     raise ArgumentError, "can't merge with #{other.class}"
58   end
59 end